Home Page class 12 @ Python

CBSE Class 12 : Data Structures

Introduction to Data Structures

CBSE Class 12 : Searching

Creation And Traversal
What is Searching?
Linear/Sequential Search
Binary Search
Insertion Of Element
Deletion Of Element

CBSE Class 12 : Sorting

What is sorting?
Bubble Sort
Selection Sort
Insertion Sort

CBSE Class 12 : Stacks

Stacks
Applications of Stacks
Implementation of Stacks

CBSE Class 12 : Queues

Queues
Applications Of Queues
Implementation of Queues

class 12 : Data Structures Traversal

Traversing a linear list

Traversing involves processing of all elements one by one upto the last element.
Steps for traversing a list :-

1. Create an empty list
2. Take input for size of the list of the list(total no. of elements)
3. Using a for loop or while loop take input for the elements of the list.
4. For traversing or displaying all the elements use a for loop.

 

#Creating and traversing a linear list
print("creating a Linear list")
size=int(input("enter the size of the linear list: "))
ar=[]
i=0
while(i<size):
    n=int(input("enter element :"))
    ar.append(n)
    i=i+1

print("traversing the list")
i=0
while(i<size):
    print(ar[i],end=' ')
    i=i+1