Purchase Solution

How to Find Unique Elements in a List

Not what you're looking for?

Ask Custom Question

I need to determine if my array is unique and in ascending order. I've got the ascending order part figured out but am not sure that I'm doing the unique part correctly. Could you check my pseudocode to see if I have it right? I not, please give me direction on how to do this.

Enter
Read N
SUB = 0
VALID_TABLE = 'Yes'
UNIQUE_TABLE = 'Yes'
DOWHILE SUB <= N
SUB = SUB + 1
Read A(SUB)
IF A(SUB-1) > A(SUB) THEN
VALID_TABLE = 'No'
ELSE
IF A(SUB) = A(SUB+1) THEN
UNIQUE_TABLE = 'No'
(ELSE)
ENDIF
ENDIF
ENDDO
Return

Purchase this Solution

Solution Summary

In this solution I demonstrate how to verify that all elements in a list are unique.

Solution Preview

The fact that you are also testing to make sure that the array is ascending makes this much easier. If the array was in ascending order ...

Purchase this Solution


Free BrainMass Quizzes
Javscript Basics

Quiz on basics of javascript programming language.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

C++ Operators

This quiz tests a student's knowledge about C++ operators.