🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

DSAA Week2-Abstract Data Types.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Week 2: Abstract Data Types Prepared by: Ms. Angilyn J. Leoncio Abstract Data Type Definition Three (3) ADTs a type (or class) for objects 1. LIST ADT whose behavior is defined by a set of value and a set 2. STACK ADT of operati...

Week 2: Abstract Data Types Prepared by: Ms. Angilyn J. Leoncio Abstract Data Type Definition Three (3) ADTs a type (or class) for objects 1. LIST ADT whose behavior is defined by a set of value and a set 2. STACK ADT of operations. 3. QUEUE ADT Primary Concept of ADT Spaghetti Code Modular Code Structured Programming Object Oriented Programming LIST ADT get() – Return an element from the list at any given position. insert() – Insert an element at any position of the list. A list contains elements of remove() – Remove the first occurrence of any element from a non-empty list. same type arranged in sequential order and removeAt() – Remove the element at a specified location from a non-empty list. following operations can be performed on the list. replace() – Replace an element at any position by another element. size() – Return the number of elements in the list. isEmpty() – Return true if the list is empty, otherwise return false. STACK ADT A Stack contains elements of same type arranged in sequential push() – Insert an element at one end of the stack called top. order. All operations takes place pop() – Remove and return the element at the top of the stack, at a single end that is top of the if it is not empty. stack and following operations peek() – Return the element at the top of the stack without can be performed:A Stack removing it, if the stack is not empty. contains elements of same type size() – Return the number of elements in the stack. arranged in sequential order. All isEmpty() – Return true if the stack is empty, otherwise return operations takes place at a single false. end that is top of the stack and isFull() – Return true if the stack is full, otherwise return false. following operations can be performed. Stack Operations Push – a term used to insert an element into the stack Pop – a term used to delete an element from the stack Top – place where all insertion and deletion takes place QUEUE ADT enqueue() – Insert an element at the end of the queue. dequeue() – Remove and return the first element of queue, if A Queue contains elements of the queue is not empty. same type arranged in sequential peek() – Return the element of the queue without removing it, if order. Operations takes place at the queue is not empty. both ends, insertion is done at size() – Return the number of elements in the queue. end and deletion is done at front. Following operations can be isEmpty() – Return true if the queue is empty, otherwise return false. performed. isFull() – Return true if the queue is full, otherwise return false. Queue Operations AddQ/InsertQ RemoveQ/DeleteQ Front – place where deletion takes effect Rear – place where insertion takes effect More questions? ASK MS. LEONCIO Email add: [email protected] Messenger: fb/angie.leoncio.5

Use Quizgecko on...
Browser
Browser