Data Structures: Comprehensive Study Notes on Arrays, Linked Lists, Stacks, and Queues, Schemes and Mind Maps of Computer science

A concise overview of fundamental data structures in computer science. It covers arrays, records, linked lists, stacks, queues, and trees, explaining their properties, operations, and memory representation. Key concepts include data types, primary keys, control flow, and linear and binary search algorithms. The notes also detail insertion and deletion operations in linear arrays, along with representations of records and linked lists in memory, making it a valuable resource for students learning about data structures. Useful for high school students.

Typology: Schemes and Mind Maps

2024/2025

Available from 10/17/2025

Anuj.awalgaonkar
Anuj.awalgaonkar 🇮🇳

3 documents

1 / 17

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Science (Paper-I)
Data Structure
Data
Data means information or set of values is called data.
Data item
A single unit of value is called data item.
Types of data item
1. Group item
A item which can divided into sub items called as group item
Eg:- student name can be divided into three sub items, that are first_name,
middle_name and last_name
2. Elementary item
A item which cannot divided into sub items called ad elementary items.
Eg:- Student roll_no cannot be divided into sub items.
Entity
Entity is an object which has certain value.
Entity set
Collection of entities called entity set.
Information
A meaningful data is called information.
Field
A single elementary unit is called field (column).
Record
Collection of field is called record (row).
File
Collection of record is called file.
Primary key
A field which has unique value called primary key.
Eg:- In a student data name of more than one student may be same but the roll
number of each student is unique so roll_no field is a primary key.
Data Structure
It is mathematical and logical model of an organization.
Here different data items are related with each other logically.
Eg:- Array, Record, Linked list, Tree, Stack, and Queue.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Data Structures: Comprehensive Study Notes on Arrays, Linked Lists, Stacks, and Queues and more Schemes and Mind Maps Computer science in PDF only on Docsity!

Computer Science (Paper-I)

Data Structure

Data Data means information or set of values is called data. ➢ Data item A single unit of value is called data item.

  • **Types of data item
  1. Group item** A item which can divided into sub items called as group item Eg:- student name can be divided into three sub items, that are first_name, middle_name and last_name 2. Elementary item A item which cannot divided into sub items called ad elementary items. Eg:- Student roll_no cannot be divided into sub items. ➢ Entity Entity is an object which has certain value. ➢ Entity set Collection of entities called entity set. ➢ Information A meaningful data is called information. ➢ Field A single elementary unit is called field (column). ➢ Record Collection of field is called record (row). ➢ File Collection of record is called file. ➢ Primary key A field which has unique value called primary key. Eg:- In a student data name of more than one student may be same but the roll number of each student is unique so roll_no field is a primary key. ➢ Data Structure It is mathematical and logical model of an organization. Here different data items are related with each other logically. Eg:- Array, Record, Linked list, Tree, Stack, and Queue.
  • **Types of data structure
  1. Linear data structure** In this data items are stored sequentially one by one in consecutive memory locations. Eg:- Array, Record, Linked list, Stack, and Queue. 2. Non-linear data structure In this data items are stored hierarchically means linear order cannot be maintained. Eg:- Tree. ➢ **Data Structure operations
  2. Traversing** Accessing each element only once is called as traversing. 2. Inserting Adding new element to the structure is called as inserting. 3. Deleting Removing element from the structure is called as deleting. 4. Searching Finding location of element is called as searching. 5. Sorting Re-arranging elements in some logical order is called as sorting. 6. Merging Combining two records in a single file is called as merging. ➢ Algorithmic notations
  • Algorithm is stepwise representation of program.
  • Algorithm divided into two parts, First part tells the purpose of algorithm, variable list, and input data. Second part is a list of steps.
  • If we want to transfer control of program to a particular step then we can use ‘goto’ statement i.e. goto step n.
  • The exit or stop shows completion of algorithm. Eg:- 1. Step 1: start Step 2: : Step 3: : Step 4: : Step 5: : Eg:- 2. Step 1: start Step 2: : Step 3: goto step 5 Step 4: : Step 5: :

ii. Double Alternative

  • It has two conditions, one is true and another is false and having two alternative paths. No Yes iii. Multiple Alternative
  • It has multiple conditions and having multiple alternative paths. Yes No Yes No Yes No If condn^1 Module A Else Module If cond Module B n (^2) If cond Module n n (^3) If condn Module A Module B

3. Looping control flow/Iterative control flow/Repetitive control flow

  • In this flow certain modules executed repeatedly until condition satisfies. No Yes ➢ Array A collection of homogenous elements is called array.
  • Syntax:- data_type name_of_array[size_of_array]; Eg:- int a[5]; a[0] a[1] a[2] a[3] a[4]
  • Size or length of array can be calculated by using following formula. Length= UB-LB+ Here, UB= Upper bound i.e. largest index number LB= Lower bound i.e. smallest index number Eg:- in above array LB=0 and UB= Length=UB-LB+ = 4 - 0+ = 5
  • Representation of Array/ Representation of Array in memory
  • Elements of array stored sequentially i.e. one by one means the elements of array stored in successive or consecutive memory location.
  • The number of cells depends on type of data elements.

Module while condn Inc/Dec Initialization

Set LA[K]=ITEM

  1. Reset N i. e. N=N+
  2. Exit Eg:- LA LA[1] LA[2] LA[3] LA[4] LB= UB= N= Suppose K=3 and ITEM=

J=

LA[4+1]=LA[4]

J=4- 1

J=

J=

LA[3+1]=LA[3]

J=3- 1

J=

J=

Condition false LA[3]= N=4+ N=

3. Deletion of Linear Array Delete(LA, N, K, ITEM)

  1. Initialize counter Set ITEM=LA[K]
  2. Repeat for J=K to N- 1 Move J+1 element upward
  3. Set LA[J]=LA[J+1] [End of loop]
  4. Reset N N=N- 1
  5. Exit

OR

3.Deletion of Linear Array Delete(LA, N, K, ITEM)

  1. Initialize counter Set ITEM=LA[K]
  2. Set J=K
  3. Repeat steps 4 & 5 while J<=N- 1
  4. Move Jth elements upward LA[J]=LA[J+1]
  5. Increase counter Set J=J+ [End of step 3 loop]
  6. Reset N i. e. N=N- 1
  7. Exit Eg:- LA LA[1] LA[2] LA[3] LA[4]

LB=

UB=

N=

Suppose K=2 and ITEM=

J=

LA[2]=LA[2+1]

J=2+

J=

J=

LA[3]=LA[3+1]

J=3+

J=

J=

Condition false N=4- 1 N=

4. Sorting/ Bubble sort Sort (DATA, N)

  1. Repeat steps 2 & 3 for K=1 to N- 1
  2. Set PTR=
  3. Repeat while PTR<=N-K 3.1 if DATA[PTR]>DATA[PTR+1] then: Interchange DATA[PTR] and DATA[PTR+1] [End of if structure] 3.2. Set PTR=PTR+ [End of inner loop] [End of step 1 outer loop]
  4. Exit Eg:- 9 5 2 4 1 Sorting:- Original list:- 2 4 1 5 4 1 5 2 1 Pass 1/ Step 1 5 2 4 5 2 4 1 9 New list:- 4 1 9 2 1 9 2 4 9 Pass 2/ Step 2 2 4 1 5 9

Eg:- 2. LA LA[1] LA[2] LA[3] LA[4] LA[5] N= ITEM= LOC= DATA[N+1]=ITEM DATA[4+1]=

LOC=

Data[1]!= LOC=1+ LOC =

LOC=

Data[2]!= LOC=2+ LOC=

LOC=

Data[3]!= LOC=3+ LOC=

LOC=

Data[4]!= LOC=4+ LOC=

LOC=

Data[5]!= Condition false Search Unsuccessful Set LOC=

6. Binary search Binary (DATA, LB, UB, ITEM, LOC)

  1. Set BEG=LB, END=UB and MID=INT(BEG+END)/
  2. Repeat steps 3 and 4 while BEG<=END and DATA[MID]!=ITEM If ITEM<DATA[MID], then: Set END=MID- 1 Else Set BEG=MID+ [End of if structure]
  3. Set MID=INT(BEG+END)/ [End of step 2 loop]
  4. If DATA[MID]=ITEM, Then: Set LOC=MID Else Set LOC=Null [End of if structure]
  5. Exit

Eg:- ➢ Pointer Array

  • Array is collection of homogenous elements.
  • Pointer is the variable that stores the value of another variable. Eg:- int a=5; int b=*a; Variable Value Memory address A 5 1000 B 5 1002
  • If each element of array works as a pointer then it is called pointer array.
  • Pointer array uses two arrays. One array contains the all members and another array contains the starting location of different groups.
  • For accessing particular field use period(.) operator. Eg:- if you want first name of students you may write: Student_info.Name.First_Name
  • If you want to access address of fourth student then you may write: Student_info.Address[1]
  • Representation of Record/ Representation of Record in memory
  • We can store record using array.
  • Because of record contain non-homogeneous data we need different array for each field. means it requires n-number of arrays for n-number of fields, that are: Roll_No [ ], First_ Name[ ], Middle_Name[ ], Last_Name[ ], Loc_Add [ ], Per_Add [ ], Gender [ ], and DOB [ ] Roll_No [ ] First_Name[ ] Middle_Name[ ] Last_Name[ ] Loc_Add [ ] Per_Add [ ] Gender [ ] DOB [ ] ➢ Linked list
  • It is linear data structure.
  • It is collection of data elements called nodes.
  • It stores data linearly one by one and linear order is maintained with the help of pointer.
  • Node is divided into two parts information part and link part.
  • Information part contains information of nodes and link part contains address of next node. Eg:- Information part Link / Pointer/ Address part Start Fig: Six node Linked list
  • Starting node contains the address of first node, then first node contains the address of second node likewise till the end of list.
  • Last node contain null pointer which is denoted by X.
  • Representation of Linked list
  • To represent linked list in memory there is need of two arrays first info[ ] and second link[ ] array. X
  • info[ ]:- this array is used to store information of all nodes.
  • link[ ]:- this array is used to store address of all next nodes. Eg:-. info[ ] link[ ] info[1] link[1] Start info[2] link[2] info[3] link[3] info[4] link[4] info[5] link[5] info[6] link[6]

B

A

C

  • Here, start from 5th^ element. Info[5]=A and link[5]=2, so the next node is 2, info[2]=B and link[2]=6 then info[6]=C and link[6]=0 i.e.null pointer means end of list. ➢ Stack
  • It is linear data structure.
  • Stack means last in first out (LIFO) i.e. only one end of stack is used to insert and delete items. Eg:- stack of books. ➢ Queue
  • It is linear data structure.
  • Queue means first in first out (FIFO) i.e. both the end of queue is opened one end is used to insert items and another is used to delete the items. Enqueue Dequeue Eg:- queue waiting for a bus at bus stop. 5
  • Depth or Height of tree:-
  • Depth of tree means maximum number of levels in a tree.
  • If tree has depth n then maximum number of nodes in a tree is 2n - 1 Eg:- If tree has depth 4 then maximum number of nodes in a given tree is: 2n - 1 = 24 - 1 = 16 - 1 = 15
  • Representation of Tree
  • There are two ways to represent tree in memory
  1. Linked Representation
  2. Sequential Representation 1. Linked Representation
  • To represent binary tree in memory using linked representation there is need of three arrays info[ ], left[ ], and right[ ] array
  • info[ ]:- this array is used to store information of all nodes.
  • left[ ]:- this array is used to store address of all left nodes.
  • right[ ]:- this array is used to store address of all right nodes. Eg:- right[ ] 5 0 0 left[ ] 4 0 0 info[ ] A B C Root info[1] left[1] right[1] info[2] left[2] right[2] info[3] left[3] right[3] info[4] left[4] right[4] info[5] left[5] right[5] C A B A X B X X^ C^ X 3

2. Sequential Representation

  • We can also represent tree in memory sequentially using single array. Eg:- info[ ] info[1] info[2] info[3] info[4] info[5] info[6] info[7] info[8] info[9] info[10] info[11] info[12] info[13] info[14] info[15]

A B C 0 0 D E 0 0 0 0 0 0 F 0

A D (^) E F B C