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

07-LISTLinked-List.pdf

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

Full Transcript

ï‚—Acombination of elements each of which is either a data type or another data structure. ï‚—Aset of associations or relationships (structure) involving the combined elements. Abstract data type (ADT) - is a specification of a set of data and the set of operations that can be performed on the...

Acombination of elements each of which is either a data type or another data structure. Aset of associations or relationships (structure) involving the combined elements. Abstract data type (ADT) - is a specification of a set of data and the set of operations that can be performed on the data. Such a data type is abstract in the sense that it is independent of various concrete implementations. The definition can be mathematical, or it can be programmed as an interface. The interface provides a constructor, which returns an abstract handle to new data, and several operations, which are functions accepting the abstract handle as an argument. ADT is typically seen in textbooks and implemented in programming languages (or their libraries) include: String, List, Stack, Queue, Priority queue, Complex number, Associative array, Multimap LIST - is nothing but a collection of similar data; it means you don't just deal with one or two variables of same type (for ex. int, char, etc) but you have a bulk of data of same type (may be all int or char or anything). To deal with such enormous amount of data, as you can even imagine, nobody will use regular variables (which can hold only one data at a time) and only solution lies in a LIST. In C, we have ARRAY to serve the purpose and that's why its a LIST. Note: an array acts as a STATIC list. STATIC LIST: Let us assume, you have the following data -- 12, 34, 56, 65, 23, 100 (all integers). Now, when you store these in an array, let's say of size 6, the array is full and looks like this – 12 34 56 65 23 100 OPERATIONS supported by a LIST: 1. Addition- adding of an element to the array (i.e. any static list) only if the current value of its index < its size and that the array doesn't have any not NULL value for that INDEX, otherwise, it will overflow. Algorithm: Step-1: Check for the current index value, whether < the array size; and the array does not have any not NULL value for that INDEX Step-2: If step-1 returns true then go to step-3 else output an error message "List overflow or data already exists" and go to step-4 Step-3: array[current_index]=element; Step-4: Repeat from 1 to 4 for the next element and index values.  C implementation: int array[listsize]; addelement(int index, int element) { if(index

Use Quizgecko on...
Browser
Browser