Skip to content

Innocentprogrammer/DSA-using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

77 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Here, I am upload all the practice codes of course DSA Using Python

Day 1:

Array & List

  • Practice Questions
  1. Given an array with some integer type values. Write a python script to sort array values.
  2. Given a list of heterogenous elements. Write a python script to remove all the non int values from the list.
  3. Write a Python script to calculate average of element of a list.
  4. Write a Python script to create a list of first N prime numbers.
  5. Write a Python script to create a list of first N terms of a Fibonacci series.

Class & Object

  • Practice Questions
  1. Define a python class Person with instance object variables name and age. Set Instance object variables in _init() nethod. Also define show() method to display name and age of a person.
  2. Define a class Circle with instance object variable radius. Provide setter and getter for radius. Also define getArea() and getCircumference() methods.
  3. Define a class Rectangle with length and breadth as instance object variables. Provide setDimensions(), showDimensions() and getArea() method in it.
  4. Define a class Book with instance object variables bookid, title, and price. Initialise them via init() method. Also define method to show book variables.
  5. Define a class Team with instance object variable a list of team member names. Provide methods to input member names and display member names.

πŸŽ‰πŸŽ‰ END OF DAY1 πŸŽ‰πŸŽ‰

Day 2:

Singly Linked List

  • Practice Questions
  1. Define a class Node to describe a node of singly linked list.
  2. Define a class SLL to implement Singly Linked List with init() method to create and initialise start reference variable
  3. Define a method is_empty() to check if linked list is empty in SLL class.
  4. In class SLL, define a method insert_at_start() to insert an element at the starting of the list.
  5. In class SLL, define a method insert_at_last() to insert an element at the end of the list.
  6. In class SLL, define a method search() to search an node with specified element value.
  7. In class SLL, define a method insert_after() to insert new node after a given node of the list.
  8. In class SLL, define a method to print all the element of list.
  9. In class SLL, implement iterator for SLL to access all the elements of the list in a sequence.
  10. In class SLL, define a method delete_first() to delete first element from the list.
  11. In class SLL, define a method delete_last() to delete last element from the list.
  12. In class SLL, define a method delete_item() to delete specified element from the list.

πŸŽ‰πŸŽ‰ END OF DAY2 πŸŽ‰πŸŽ‰

Day 3:

Doubly Linked List

  • Practice Questions
  1. Define a class Node to describe a node of Doubly linked list.
  2. Define a class DLL to implement Doubly Linked List with init() method to create and initialise start reference variable
  3. Define a method is_empty() to check if linked list is empty in DLL class.
  4. In class DLL, define a method insert_at_start() to insert an element at the starting of the list.
  5. In class DLL, define a method insert_at_last() to insert an element at the end of the list.
  6. In class DLL, define a method search() to search an node with specified element value.
  7. In class DLL, define a method insert_after() to insert new node after a given node of the list.
  8. In class DLL, define a method to print all the element of list.
  9. In class DLL, implement iterator for DLL to access all the elements of the list in a sequence.
  10. In class DLL, define a method delete_first() to delete first element from the list.
  11. In class DLL, define a method delete_last() to delete last element from the list.
  12. In class DLL, define a method delete_item() to delete specified element from the list.

πŸŽ‰πŸŽ‰ END OF DAY3 πŸŽ‰πŸŽ‰

Day 4

Circular Linked List

  • Practice Questions
  1. Define a class Node to describe a node of Circular linked list.
  2. Define a class CLL to implement Circular Linked List with init() method to create and initialise last reference variable
  3. Define a method is_empty() to check if linked list is empty in CLL class.
  4. In class CLL, define a method insert_at_start() to insert an element at the starting of the list.
  5. In class CLL, define a method insert_at_last() to insert an element at the end of the list.
  6. In class CLL, define a method search() to search an node with specified element value.
  7. In class CLL, define a method insert_after() to insert new node after a given node of the list.
  8. In class CLL, define a method to print all the element of list.
  9. In class CLL, define a method delete_first() to delete first element from the list.
  10. In class CLL, define a method delete_last() to delete last element from the list.
  11. In class CLL, define a method delete_item() to delete specified element from the list.
  12. In class CLL, implement iterator for CLL to access all the elements of the list in a sequence.

πŸŽ‰πŸŽ‰ END OF DAY4 πŸŽ‰πŸŽ‰

Day 5

Circular Doubly Linked List

  • Practice Questions
  1. Define a class Node to describe a node of Circular doubly linked list.
  2. Define a class CDLL to implement Circular Doubly Linked List with init() method to create and initialise start reference variable
  3. Define a method is_empty() to check if linked list is empty in CDLL class.
  4. In class CDLL, define a method insert_at_start() to insert an element at the starting of the list.
  5. In class CDLL, define a method insert_at_last() to insert an element at the end of the list.
  6. In class CDLL, define a method search() to search an node with specified element value.
  7. In class CDLL, define a method insert_after() to insert new node after a given node of the list.
  8. In class CDLL, define a method to print all the element of list.
  9. In class CDLL, define a method delete_first() to delete first element from the list.
  10. In class CDLL, define a method delete_last() to delete last element from the list.
  11. In class CDLL, define a method delete_item() to delete specified element from the list.
  12. In class CDLL, implement iterator for CDLL to access all the elements of the list in a sequence.

πŸŽ‰πŸŽ‰ END OF DAY5 πŸŽ‰πŸŽ‰

Day 6

  • Practice questions on the GFG platform of Basic and Easy level.

πŸŽ‰πŸŽ‰ END OF DAY6 πŸŽ‰πŸŽ‰

Day 7

Stack Using List

  • Practice Questions
  1. Define a class Stack to implement stack data structure using list. Define init() method to create an empty list object as instance object member of Stack.
  2. Define a method is_empty() to check if the stack is empty in Stack class.
  3. In Stack class, define push() method to add data onto the stack.
  4. In Stack class, define pop() method to remove top element from the stack.
  5. In Stack class, define peak() method to return top element on the stack.
  6. In Stack class, define size() method to return the size of the stack that is number of element items present in the stack.

Stack By Extending List

  • Practice Questions
  1. Define a class Stack to implement stack data structure by extending list class.
  2. Define a method is_empty() to check if stack is empty in Stack class.
  3. In Stack class, define push() method to add data onto the stack.
  4. In Stack class, define pop() method to remove top element from the stack.
  5. In Stack class, define peak() method to return top element on the stack.
  6. In Stack class, define size() method to return size of the stack that is number of items present in the stack.
  7. Implement a way to restrict use of insert() method of list class from stack object.

πŸŽ‰πŸŽ‰ END OF DAY7 πŸŽ‰πŸŽ‰

Day 8

Stack Using Linked List Concept

  • Practice Questions
  1. Define a class Stack to implement stack data structure using Singly Linked List concept. Define init() method to initialise start reference variable and item_count variable to keep track of number of elements in stack.
  2. Define a method is_empty() to check if stack is empty in Stack class.
  3. In Stack class, define push() method to add data onto the stack.
  4. In Stack class, define pop() method to remove top element from the stack.
  5. In Stack class, define peak() method to return top element on the stack.
  6. In Stack class, define size() method to return size of the stack that is number of items present in the stack.

πŸŽ‰πŸŽ‰ END OF DAY8 πŸŽ‰πŸŽ‰

Day 9

Stack Using Single Linked List File

  • Practice Questions
  1. Import module containing singly linked list code in your python file.
  2. Define a class Stack to implement stack data structure. Define init() method to create Singly Linked List(SLL) object
  3. Define a method is_empty() to check if the stack is empty in Stack class.
  4. In Stack class, define push() method to add data onto the stack.
  5. In Stack class, define pop() method to remove top element from the stack.
  6. In Stack class, define peak() method to return top element on the stack.
  7. In Stack class, define size() method to return size of the stack that is number of items present in the stack.

Stack By Extending Singly Linked List File

  • Practice Questions
  1. Import module containing singly linked list code in your python file.
  2. Define a class Stack to implement stack data structure by inheriting linked list class.
  3. Define a method is_empty() to check if the stack is empty in Stack class.
  4. In Stack class, define push() method to add data onto the stack.
  5. In Stack class, define pop() method to remove top element from the stack.
  6. In Stack class, define peak() method to return top element on the stack.
  7. In Stack class, define size() method to return size of the stack that is number of item present in stack.

πŸŽ‰πŸŽ‰ END OF DAY9 πŸŽ‰πŸŽ‰

Day 10

Queue Using List

  • Practice Questions
  1. Define a class Queue to implement queue data structure using list. Define init() method to create an empty list object as instance object member of Queue.
  2. Define a method is_empty() to check if the queue is empty in Queue class.
  3. In Queue class, define enqueue() method to add data at the rear end of the queue.
  4. In Queue class, define dequeue() method to remove front element from the queue.
  5. In Queue class, define get_front() method to return front element of the queue.
  6. In Queue class, define get_rear() method to return rear element of the queue.
  7. In Queue class, define size() method to return size of the queue that is number of items present in the queue.

πŸŽ‰πŸŽ‰ END OF DAY10 πŸŽ‰πŸŽ‰

Day 11

Queue Using Linked List

  • Practice Questions
  1. Define a class Queue to implement queue data structure using singly linked list concept. Define init() method to initialise front and rear reference variable; and item_count variable to keep track of number of elements in the queue.
  2. Define a method is_empty() to check if the queue is empty in Queue class.
  3. In Queue class, define enqueue() method to add data into the queue.
  4. In Queue class, define dequeue() method to remove front element from the queue.
  5. In Queue class, define get_front() method to return front element of the queue.
  6. In Queue class, define get_rear() method to return rear element of the queue.
  7. In Queue class, define size() method to return size of the queue that is number of items present in the queue.

πŸŽ‰πŸŽ‰ END OF DAY11 πŸŽ‰πŸŽ‰

Day 12

Deque Using List

  • Practice Questions
  1. Define a class Deque to implement deque data structure using list. Define init() method to create an empty list object as instance object member of Deque.
  2. Define a method is_empty() to check if deque is empty in Deque class.
  3. In Deque class, define insert_front() method to add data at front end of the deque.
  4. In Deque class, define insert_rear() method to add data at rear end of the deque.
  5. In Deque class, define delete_front() method to remove front element from the deque.
  6. In Deque class, define delete_rear() method to remove rear element from the deque.
  7. In Deque class, define get_front() method to return front element of the deque.
  8. In Deque class, define get_rear() method to return rear element of the deque.
  9. In Deque class, define size() method to return size of the deque that is number of items present in deque.

Deque Using Doubly Linked List

  • Practice Questions
  1. Define a class Node with instance object member Variables prev, item & next.
  2. Define a class Deque to implement deque data structure using doubly linked list concept. Define init() method to initialise front and rear reference variable; and item_count variable to keep trrack of number of elements in the deque.
  3. Define a method is_empty() to check if the Deque class.
  4. In Deque class, define insert_front() method to add data at front end of the deque.
  5. In Deque class, define insert_rear() method to add data at rear end of the deque.
  6. In Deque class, define delete_front() method to remove front element from the deque.
  7. In Deque class, define delete_rear() method to remove rear element from the deque.
  8. In Deque class, define get_front() method to return front element of the deque.
  9. In Deque class, define get_rear() method to return rear element of the deque.
  10. In Deque class, define size() method to return size of the deque that is number of items present in deque.

πŸŽ‰πŸŽ‰ END OF DAY12 πŸŽ‰πŸŽ‰

Day 13

Priority Queue Using List

  • Practice Questions
  1. Define a class PriorityQueue to implement priority queue data structure using list. Provide init() method to create a list object (inittally empty).
  2. Define a push method in PriorityQueue class to insert new data with given priority.
  3. Define a pop method in PriorityQueue class, which returns the highest priority data stored in the priority queue data structure. Raise exception in priority queue is empty.
  4. Define a is_epmty method in PriorityQueue class to check if the priority queue is empty.
  5. In class PriorityQueue, define a method size to return the number of elements present in the priority queue.

Priority Queue Using Doubly Linked List

  • Practice Questions
  1. Define a Node class with instance member variables item, priority and next.
  2. Define a class PriorityQueue to implement priority queue data structure using singly linked list. Provide init() method to create a start reference variable (initially containing None) and item_count variable (initially 0).
  3. Define a push method in PriorityQueue class to insert new data with given priority.
  4. Define a pop method in PriorityQueue class, which returns the highest priority data stored in the priority queue data structure. Raise exception if priority queue is empty.
  5. Define a is_empty method in PriorityQueue class to check if priority queue is empty.
  6. In class PriorityQueue, define a method size to return the number of elements present in priority queue.

πŸŽ‰πŸŽ‰ END OF DAY13 πŸŽ‰πŸŽ‰

Day 14

Recursion

  • Practice Questions
  1. Write a recursion function to print first N natural numbers.
  2. Write a recursive function to print first N natural numbers in reverse order.
  3. Write a recursive function to print first N odd natural numbers.
  4. Write a recursive function to print first N even natural nubmers.
  5. Write a recursive function to print first N odd natural numbers in reverse order.
  6. Write a recursive function to print first N even natural nubmers in reverse order.
  7. Write a recursive function to calculate sum of first N natural numbers.
  8. Write a recursive function to calculate sum of first N odd natural numbers.
  9. Write a recursive function to calculate sum of first N even natural numbers.
  10. Write a recursive function to calculate factorial of a number.
  11. Write a recursive function to calculate sum of square of first N natural numbers.

πŸŽ‰πŸŽ‰ END OF DAY14 πŸŽ‰πŸŽ‰

Day 15

BST Insertion

  • Practice Questions
  1. Define a class Node with instance variables left, item, and right. The variables left and right are used to refer left and right child node. The item variable is used to hold data item.
  2. Define a class BST to implement Binary Search Tree data structure. Make init() method to create root instance variable to hold the reference of root node.
  3. In class BST, define insert method to store new data item in the binary search tree.
  4. In class BST, define a search method to find a given item in the binary search tree and return the node reference. It returns None if search failed.
  5. In class BST, define a method to implement inorder traversal.
  6. In class BST, define a method to implement preorder traversal.
  7. In class BST, define a method to implement postorder traversal.

πŸŽ‰πŸŽ‰ END OF DAY15 πŸŽ‰πŸŽ‰

Day 16

BST Deletion

  • Practice Questions
  1. In class BST, define a method to find minimum value item node.
  2. In class BST, define a method to find maximum value item node.
  3. In class BST, define a method to delete a node from binary search tree.
  4. In class BST, define a method size to return the number of elements present in the BST.

πŸŽ‰πŸŽ‰ END OF DAY16 πŸŽ‰πŸŽ‰

Day 17

Adjacency Matrix Implementation of Graph

  • Practice Questions
  1. Write a class Graph to implement adjacency matrix representation of simple and undirectes graph.
  2. In class Graph, define init() method to initialise vertex_count and adj_matrix (list of lists)
  3. In class Graph, define add_edge() method add an edge in the graph with given weight.
  4. In class Graph, define remove_edge() method to remove an edge from the graph.
  5. In class Graph, define has_edge() method to check whether two given vertices are connected by an edge or not.
  6. In class Graph, define print_adj_matrix() method to print adjacency matrix.

Adjacency List Implementation of Graph

  • Practice Questions
  1. Write a class Graph to implement list representation of graph data structure.
  2. In class Graph, define init() method to initialise instance object variable vertex_count and a dict adj_list where key is vertex number and value is a list of adjacent vertices.
  3. In class Graph, define add_edge() method add an edge in the graph with given vertices and weight.
  4. In class Graph, define remove_edge() method to remove an edge from the graph.
  5. In class Graph, define has_edge() method to check whether an edge exists or not for a given pair of vertices.
  6. In class Graph, define print_adj_list() method to print adjacency list of graph.

πŸŽ‰πŸŽ‰ END OF DAY17 πŸŽ‰πŸŽ‰

Day 18

Bubble Sort and Modified Bubble Sort

  • Practice Questions
  1. Write a python function to implement bubble sort.
  2. Write a python function to implement modified bubble sort.

Selection Sort

  • Practice Question
  1. Write a python function to implement selection sort.

πŸŽ‰πŸŽ‰ END OF DAY18 πŸŽ‰πŸŽ‰

Day 19

Insertion Sort

  • Practice Question
  1. Write a python function to implement Insertion sort

πŸŽ‰πŸŽ‰ END OF DAY19 πŸŽ‰πŸŽ‰

Day 20

Quick Sort

  • Practice Question
  1. Write a python function to implement quick sort.

Merge Sort

  • Practice Question
  1. Write a python function to implement merge sort.

πŸŽ‰πŸŽ‰ END OF DAY20 πŸŽ‰πŸŽ‰

Day 21

Heap and Heap Sort

  • Practice Question
  1. Define a class Heap to implement Heap data structure with init method to create empty heap list.
  2. In class Heap, define a method to create a heap from a given list of element.
  3. In class Heap, define a method insert to insert a given element in the heap at appropriate position.
  4. In class Heap, define a top method which returns the top element of heap. Raise an exception if Heap is empty.
  5. Define a class EmptyHeapException to describe custom exception.
  6. In class Heap, define a method delete which delete the top element and returns it. Raise an exception if Heap is empty.
  7. In class Heap, define a method heapSort to sort a given list with help of heap.

πŸŽ‰πŸŽ‰ END OF DAY21 πŸŽ‰πŸŽ‰

Day 22

Searching

  • Practice Questions
  1. Write a python function to implement Linear Search.
  2. Write a python function to implement Binary Search.

πŸŽ‰πŸŽ‰ END OF DAY22 πŸŽ‰πŸŽ‰

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages