Jump to content

Abstract data types

- - - - -

  • Please log in to reply
17 replies to this topic

#1
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Operation_1(A) : if ( ALPHABET[value(A)] )
return ERROR
else
ALPHABET[value(A)] = true ;

Operation_2(A) : return ALPHABET[value(A)] ;

Operation_3() : int N = 0 ;
for (int i=0; i<26; i++)
if ( ALPHABET[i] )
N++ ;
return N ;

Operation_4(A) : if ( ! ALPHABET[value(A)] )
return ERROR
else
ALPHABET[value(A)] = false ;

Operation_5() : int N = 0 ;
for (int i=0; i<26; i++)
if ( ALPHABET[i] )
return FALSE ;
return TRUE ;


I have the function value() who takes an upper-case letter and returns an integer value 0 for "A"...25 for "Z". All the letters are mapped into 26 boolean elements of a linear array ALPHABET and initialised to FALSE.

My question is what abstract data type are implemented by this operations, i think is Queue but im not 100% sure. Can any one make it clearer?

Thank you

#2
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I don't see any reference to Queue in your pseudocode. Where did you get the idea that it was Queue?

An Abstract Data Type is simply a form for describing similar data types that behave similarly or have similar symantics. (For a more thorough explanation of ADT, see Abstract data type - Wikipedia, the free encyclopedia )

In your pseudocode, what data types are mentioned that aren't primitives? (Hint: Primitives are things like int, double...)
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#3
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
I have this exercise and i have to state what data type is implemented by these operations...(Set, Stack, Queue, Graph or Tree)

#4
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I guess I'm not understanding the question. Is the exercise asking which ADT's are implemented by the Set, Stack, Queue, Graph, and Tree?
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#5
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
State what abstract data type is implemented by these operations

Exactly, this is the question...

#6
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
I guess I'm a little confused because Set, Stack, Queue, etc... aren't technically operations, they are types. They aren't really abstract types, they're template classes. Abstract classes are more for deriving subclasses which mimic functionality of the parent abstract class. (In C++, it's done by declaring the methods with the "virtual" keyword.) Template classes are for writing a class beforehand before you know what datatypes they will operate on.

Could you post more information on the question please?

If somebody else is picking up on what this is asking, please feel free to help me out.
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#7
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Thats all i have for the exercise, given 5 operations and a question. By the way in my course learned that some ADTs are Set, Stack, Queue, Graph, and Tree. Is that wrong?

#8
gregwarner

gregwarner

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 853 posts
  • Location:Arkansas
No, not wrong, I guess I was just confused by the wording.

As far as the question goes, I don't know how to answer because the question is asking, "what abstract data type is implemented by these operations." Strictly speaking, Set, Stack, Queue, etc., aren't operations. Operations would be things like push, pop, add, remove, etc. Operations are the things you can perform on data types such as set, stack, queue, etc.

I also don't know how to answer what abstract data type is implemented by set, stack, queue, etc., because those are the abstract data types. I don't know that any abstract data type is implemented by them.

If you could seek some clarification on the question maybe I could help you more.

Unless someone else is seeing the obvious that I'm missing?
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.

– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#9
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
ok, i appreciate your effort until now, thank you

#10
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
What you need to do is look at each of the operations listed, and figure out whether it corresponds to push, pop, isempty, etc. For pop, does it pop the value that was pushed last, or pushed first?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#11
toto_7

toto_7

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 295 posts
Still confused!!! :S If pop the last pushed is stack, if pop the first is queue. right?

#12
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Correct.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users