Skip to content

manikanta20-01/Rohit-dsa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DSA and C++ Learning Project

Project Overview

This project is focused on learning Data Structures and Algorithms (DSA) along with C++. The primary mentor for this project is Rohit Negi.

Syllabus -

Data Structures

  1. Arrays
  2. Linked Lists
    • Singly Linked Lists
    • Doubly Linked Lists
    • Circular Linked Lists
  3. Stacks
  4. Queues
    • Linear Queues
    • Circular Queues
  5. Trees
    • Binary Trees
    • Binary Search Trees
    • AVL Trees
    • Heap
  6. Graphs
    • Graph Representation (Adjacency List, Adjacency Matrix)
    • Depth-First Search (DFS)
    • Breadth-First Search (BFS)

Algorithms

  1. Time and Space Complexity Analysis
  2. Sorting and Searching
    • Bubble Sort
    • Selection Sort
    • Insertion Sort
    • Merge Sort
    • Quick Sort
    • Binary Search
  3. Recursion
  4. Dynamic Programming
  5. Greedy Algorithms
  6. Graph Algorithms
    • Dijkstra's Algorithm
    • Kruskal's Algorithm
    • Prim's Algorithm
    • Depth-First Search (DFS) and Applications
    • Breadth-First Search (BFS) and Applications
  7. Divide and Conquer
  8. Backtracking

C++ Programming

  1. Basics of C++
    • Data types
    • Control structures (if, else, switch, loops)
    • Functions
    • Classes and Objects
    • File handling
  2. Object-Oriented Programming (OOP)
    • Inheritance
    • Polymorphism
    • Encapsulation
    • Abstraction
  3. Standard Template Library (STL)
    • Vectors
    • Lists
    • Maps
    • Sets

Daily Progress Log

Date: [09-10-2023]

  • Progress: Day 22/180 Introduction to Arrays in c++

1: Take 20 elements from user input and find its sum with the help of an array.

2: Calculate the average of elements in an array of size 18.

3: Find the index of a specific element in an array, if the element is nor present, print -1. Ask the size of the array from the user and then implement it.

4: Create an array of char types and store ‘a’ to ‘z’ in it. Then print the element of the arrays.

5: Find the second largest element in an array of unique elements of size n. Where n>3.

6: Find the third smallest element in an array of unique elements size n. Where n>3.

7: What is Byte addressable?

Date: [MM/DD/YYYY]

  • Progress:
    • [Brief update on progress for the day]

[Add similar sections for each day, describing the progress made.]

How to Use this Repository

[Provide instructions on how to navigate and utilize the project repository for learning DSA and C++.]

Contact

For any queries or assistance related to this project, feel free to contact:

Data_Structure_and_Algorithm | |-- Basic_Data_Structures | |-- Arrays | |-- Strings | |-- Linked_Lists | |-- Stacks | └─ Queues | |-- Advanced_Data_Structures | |-- Trees | | |-- Binary_Trees | | |-- Binary_Search_Trees | | |-- AVL_Trees | | └─ B-Trees | | | |-- Graphs | | |-- Graph_Representation | | | |- Adjacency_Matrix | | | └ Adjacency_List | | | | | |-- Depth-First_Search | | |-- Breadth-First_Search | | |-- Shortest_Path_Algorithms | | | |- Dijkstra's_Algorithm | | | └ Bellman-Ford_Algorithm | | | | | └─ Minimum_Spanning_Tree | | |- Prim's_Algorithm | | └ Kruskal's_Algorithm | | | |-- Heaps | | |-- Min_Heap | | |-- Max_Heap | | └─ Heap_Sort | | | |-- Hash_Tables | |-- Disjoint_Set_Union | |-- Trie | |-- Segment_Tree | └─ Fenwick_Tree | |-- Algorithmic_Paradigms | |-- Brute_Force | |-- Divide_and_Conquer | |-- Greedy_Algorithms | |-- Dynamic_Programming | |-- Backtracking | |-- Sliding_Window_Technique | |-- Two_Pointer_Technique | └─ Divide_and_Conquer_Optimization | |-- Merge_Sort_Tree | └─ Persistent_Segment_Tree | |-- Searching_Algorithms | |-- Linear_Search | |-- Binary_Search | |-- Depth-First_Search | └─ Breadth-First_Search | |-- Sorting_Algorithms | |-- Bubble_Sort | |-- Selection_Sort | |-- Insertion_Sort | |-- Merge_Sort | |-- Quick_Sort | └─ Heap_Sort | |-- Graph_Algorithms | |-- Depth-First_Search | |-- Breadth-First_Search | |-- Topological_Sort | |-- Strongly_Connected_Components | └─ Articulation_Points_and_Bridges | |-- Dynamic_Programming | |-- Introduction_to_DP | |-- Fibonacci_Series_using_DP | |-- Longest_Common_Subsequence | |-- Longest_Increasing_Subsequence | |-- Knapsack_Problem | |-- Matrix_Chain_Multiplication | └─ Dynamic_Programming_on_Trees | |-- Mathematical_and_Bit_Manipulation_Algorithms | |-- Prime_Numbers_and_Sieve_of_Eratosthenes | |-- Greatest_Common_Divisor | |-- Least_Common_Multiple | |-- Modular_Arithmetic | └─ Bit_Manipulation_Tricks | |-- Advanced_Topics | |-- Trie-based_Algorithms | | |-- Auto-completion | | └─ Spell_Checker | | | |-- Suffix_Trees_and_Arrays | |-- Computational_Geometry | |-- Number_Theory | | |-- Euler's_Totient_Function | | └─ Mobius_Function | | | └─ String_Algorithms | |-- KMP_Algorithm | └─ Rabin-Karp_Algorithm | |-- Online_Judges_and_Practice_Platforms | |-- LeetCode | |-- HackerRank | |-- CodeChef | |-- Codeforces | └─ HackerEarth | └─ Interview_Preparation |-- Commonly_Asked_DSA_Interview_Questions |-- Mock_Interviews |-- Problem-Solving_Strategies |-- Time_and_Space_Complexity_Analysis └─ Coding_Patterns_and_Techniques

------------------- END -------------------

Linked list

Array vs Linked List

alt text

  • Array allocates the memory at contiguous location but linked list are different.

  • Linked list is a combination of data and it's next node address called node

alt text

create a linked list

#include <iostream>
using namespace std;

class Node 
{
    public:
    int data;
    Node *next;
    
    Node(int value)
    {
        data = value;
        next = NULL;
    }
};

int main()
{
    Node *Head;
    Head = new Node(4);
    
    cout << Head->data << endl;
    cout << Head->next << endl;

    return 0;
}

Insertion

Insertion Head

alt text alt text alt text

class Node
{
public:
  int data;
  Node *next;
    Node (int value)
  {
	data = value;
	next = NULL;
  }

};

int main ()
{
  // create Node 
  Node *Head;
  Head = NULL;
//   cout << Head->data << endl;
//   cout << Head->next << endl;

  // array
  int arr[] = { 2, 4, 6, 8 };


  // check if LL is exist
  for (int i = 0; i < 4; i++)
	{

	  if (Head == NULL)
		{
		  Head = new Node (arr[i]);
		}

	  // check if LL is not exist
	  else
		{
		  Node *temp;
		  temp = new Node (arr[i]);
		  temp->next = Head;
		  Head = temp;
		}
	}
  // print the LL 
  Node *temp = Head;
  while (temp)
	{
	  cout << temp->data << " " << endl;
	  temp = temp->next;

	}
  return 0;
}

Insertion End

alt text

  • Step 1: IF PTR = NULL Write OVERFLOW Go to Step 1 [END OF IF]
  • Step 2: SET NEW_NODE = PTR
  • Step 3: SET PTR = PTR - > NEXT
  • Step 4: SET NEW_NODE - > DATA = VAL
  • Step 5: SET NEW_NODE - > NEXT = NULL
  • Step 6: SET PTR = HEAD
  • Step 7: Repeat
  • Step 8 while PTR - > NEXT != NULL
  • Step 8: SET PTR = PTR - > NEXT [END OF LOOP]
  • Step 9: SET PTR - > NEXT = NEW_NODE
  • Step 10: EXIT
#include <iostream>
using namespace std;
class Node
{
public:
  int data;
  Node *next;
    Node (int value)
  {
	data = value;
	next = NULL;
  }

};

int
main ()
{
  Node *Head, *Tail;
  Tail = Head = NULL;

  int arr[] = { 2, 4, 6, 8, 10 };
  for (int i = 0; i < 5; i++)
	{

	  // IF LL IS EMPTY

	  if (Head == NULL)
		{
		  Head = new Node (arr[i]);
		  Tail = Head;

		}
	  // IF LL IS NOT EMPTY
	  else
		{
		  Tail->next = new Node (arr[i]);
		  Tail = Tail->next;


		}
	}
  Node *temp;
  temp = Head;

  // print the LL

  while (temp)
	{
	  cout << temp->data << " ";
	  temp = temp->next;

	}

  return 0;
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages