0% found this document useful (0 votes)
10 views36 pages

CS3301 Data Structure Unit wise

Gahahah

Uploaded by

shamrcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
10 views36 pages

CS3301 Data Structure Unit wise

Gahahah

Uploaded by

shamrcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 36
UNITI Topics ‘eat / Reference book Page No. ‘Abstract Data Types (ADTs) 37 List ADT ~ array-based implementation 38-59 i Mark Allen Weiss, “Data [55 Tinked list implementation Poe ake rene |—_________) Analysis in C*, 2nd Edition, singly Tinked lists Pearson Education, 1997, 0 circularly linked lists 8 doubly-linked lists 6 applications of lists —Polynomial | Manipulation ‘All operations (Insertion, Deletion, B Merge, Traversal). S| Question No Course | Blooms Outcom | Taxanom © Adata structure is a which would allow eff data retrieval and us © A data strucyure j not only inhe also their, og —f ‘NY en | ytew! 1 What is a data structure? C3 method intzing and storing data rganizing data that considers BTLI 2 | Wh iructures? Rent reuse. again and again in various applications, aNguctures allow us to achieve an important goal: fe data structure has been implemented, it can be used Gita | BTLI 3 | List some common data structures, Stacks Queues: Lists Trees Graphs Tables Gia [BLT How data structures are classified? Git | BTL1 Data structures are classified into two categories based on how the data items are ‘operated: i. Primitive data structure ii, Non-Primitive data structure a. Linear data structure b, Non-linear data structure Differentiate linear and non-linear data structure. Gut Linear data structure ‘Non-linear data structure ‘Data are arranged in linear or | Data are not arranged in linear sequential manner manner BIL2 Every items is related to its | Every item is attached with previous many other ° and next item items Data items can be traversed in | Data tems cannot be tra a ina single run. single run. Tmplementation is easy ‘Example: array, stack, queue, linked list Define ADT (Abstract Data Git |BTLT ‘An abstract data typ © a set of operations and ‘mathematical abstractio ‘of operations is implemented. Objects like lists, along with their operation, can bbe viewed as a g 'Ypes, just as integers, real numbers and Booleans, Mi fe ‘of ADT. Gilt BTL? iDi jgram into small functions ii, Easy Wo debug and maintain iii, Easy to modify b, Reuse i, Define some operations only once and reuse them in future cc, Easy to change the implementation Define List ADT Git |BTLI A list is a sequence of zero or more elements of a given type. The list is represented as sequence of elements separated by comma. AL. A2, A3...0AN Where N>0 and A is of type element ‘What are the ways of implementing linked list? ‘The list can be implemented in the following ways: i, Array implementation ii, Linked-list implementation Cursor implementation cant BILI 10 ‘What are the types of linked lists? ‘There are three types i, Singly linked list Doubly linked list iii. Circularly linked list cit BILT i How the singly linked lists can be represented? data next Each node has two elements Data Next Le [ts Yt cat BTL! How the doubly linked list can be represented? ee ‘of nodes where nodes are connected by forwarded, backward link. © Each node has t — 1, Address of 2. Da Git BILT 3 b. Implementation of ADT can be changed without requiring changes to the program that uses the ADT Gin BTLI ‘When singly linked list can be represented as circular linked list? In a singly linked list, all the nodes are connected with forward links to the next nodes in the list. The last node has a next field, NULL. In order to implement the circularly linked cid BTL I Tists from singly linked lists, the last node"s next fieldis connected to the first node. (Git C1} CCTs ‘When doubly linked list can be represented as circular linked list? In a doubly linked list, all nodes are connected with forward and backward links to the ‘next and previous nodes respectively. In order to implement circular linked lists from doubly linked lists, the first node's previous field is connected to the last node and the last node’s next field is connected to the first node. Galt BILI Where cursor implementation can be used? ‘The cursor implementation of lists is used languages such as BASIC and FORTRAN that do not support pointers. iMportin features of the cursor ‘implementation of linked are as follows” © The data are stored in a structure contains dat index to the next structupé of structures. Bach from the system's global BILI 7 "ATYile system, the metadata of a large file is organized ist of FAT entries. 4. Simple memory allocators use a free list of unused memory regions, basically a linked list with the list pointer inside the free memory itself. Hit BIL 18 ‘What are the advantages of linked list?(apr/may 2019) a. Save memory space and easy to maintain b. IN is possible to retrieve the element at a particular index €. It is possible to traverse the list in the order of increasing index. 4. It is possible to change the element at a particular index to a different value,without affecting any other elements. int BILI 19 | Mention the demerits of linked list ca] BTL2 a. [tis not possible to go backwards through the list 'b. Unable to jump to the beginning of list from the end. 20 | The polynomial equation can be represented with linked list | G11 | BTL 2 1s follows: Coefficient Exponent Next node link struct polynomial { int coefficient; int exponent; struct polynomial *next; h 21 | What are the operations performed in list? Git | BTLI The following operations can be performed on a list i. Insertion a, Insert at beginning b. Insert at end cc. Insert after specific node ® ii, Deletion a. Delete at beginning b, Delete at end ¢. Delete after specific node 4d. Delete before specific node ° . Merging aN ees < d, Insert before specific node N 22 | What are the merits and deme 5; implementation of lists? Merits © Fast, random f elements © Memory ef less amount of memory is required défftion operations are very slow since the ld be «Redundant memory space ~ difficult to estimate the size of array. Gin BILI 23 | What is a circular linked list? A ccitcular linked list is a special type of linked list that supports traversing from the end Cf the list to the beginning by making the last node point back to the head of the list, cad BTL ory ‘What are the advantages in the array implementation of list? a. Print list operation can be carried out at the linear time Find Kth operation takes a constant time Girt BTLI ‘What is the need for the header? Header of the linked list is the first element in the list and it stores the number of elements in the list. It points to the first data element of the list. Gini BTLI 26 List three examples that uses linked list? a, Polynomial ADT bRadix sort Multi lists Git BTLI oy List out the different ways to implement the list? 1. Array Based Implementation 2. Linked list Implementation Singly linked list ii, Doubly linked list iii, Cursor based linked list LI 28 Write the routine for insertion operation list. Void Insert (ElementType X, List L, Posfliy {Position TmpCell; lloc(sizeof{struct Node] i NULL) FatalError(“Out of space!!!" ‘TmpCell->Element =: P->Next=TmpCell, * Cant BILS 2 cess any memory directly. jw the position of the middle element and other ts are easily accessible too, we can easily perform TARY SEARCH in array. Gini BILS 30 Disadvantages of Array over Linked List. 1, Total number of elements need to be mentioned or the ‘memory allocation needs to be done at the time of array creation 2. The size of array, once mentioned, cannot be increased in the program. If number of elements entered exceeds the Gant BILS size of the array ARRAY OVERFLOW EXCEPTION occurs. 3 ‘Advantages of Linked List over Array. 1. Size of the list doesn't need to be mentioned at the beginning of the program. 2. As the linked list doesn't have a size limit, we can go on adding new nodes (elements) and increasing the size of the list to any extent Gini BILS 2 Disadvantages of Linked List over Array. 1. Nodes do not have their own address. Only the address of the first node is stored and in order to reach any node, we need to traverse the whole list from beginning to the desired node. 2, Asall Nodes don't have their particular address, BINARY SEARCH cannot be performed cud BILS 33 list(apr/may 2019) Linked list are used to create trees and graphs. Cireular. In circular linked list the last node adress part holds t the first node hence forming a circular chain likes list isa linear data structure which consists sequence . < Dian aa NT ad aed se o of Enlist the various operations that ean be ‘on data structure. ‘Various operations that can be perf 1 data structure are + Create + Insertion of element + Searching for the desired clement + Sorting the ek the data structure * Reversing Gia 35 cant 7 Operating system- the data structure like priority queues are used for scheduling the jobs inthe operating system. * Compiler design- the tree data structure is used in parsing the source program, Stack data structure is used in handling recursive calls. + Database management system- The file data structure is used in database management systems. Sorting and searching techniques can be applied an these data in the file + Numerical analysis package- the array is used to perform the numerical analysis on the given set of data. * Graphies- the array and the linked list are useful in graphics applications. + Artificial intelligence- the graph and trees are used forthe applications like building expression trees, game playing. cant

You might also like