Skip to content

Commit

Permalink
Merge pull request #1 from Krish1920/krish
Browse files Browse the repository at this point in the history
Create a folder with basic DSA problems fineanmol#7818
  • Loading branch information
Krish1920 authored Oct 14, 2024
2 parents 759e057 + e6c0640 commit d617def
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
35 changes: 35 additions & 0 deletions DSA Problems/Problems.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
𝟭𝗗 𝗔𝗿𝗿𝗮𝘆

1. How would you find the second-largest element in an array with the least number of comparisons?
2. Write a function to move all zeros in an array to the end, maintaining the relative order of the other elements.
3. How would you reverse an array in place?
4. Given an array of integers, write an algorithm to find the subarray with the largest sum.
5. Write a function to rotate an array by 'k' positions.
6. How would you merge two sorted arrays into a single sorted array?

𝗧𝗶𝗺𝗲 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆

1. What is Big O notation, and why is it important in analyzing time complexity?
2. Explain the time complexity of binary search and how it can be optimized in certain cases.
3. How would you calculate the time complexity of a recursive algorithm, and how does it differ from iterative approaches?
4. What are the time complexities for the best, worst, and average cases of merge sort and quicksort?
5. Given a set of cities and the distance between each pair, how would you solve the Traveling Salesman Problem (TSP), and what is its time complexity?
6. What is the difference between Big O, Big Theta (Θ), and Big Omega (Ω) notations? Provide examples for each.

𝗟𝗶𝗻𝗸𝗲𝗱 𝗟𝗶𝘀𝘁𝘀

1. How do you reverse a singly linked list in place?
2. How would you detect a cycle in a linked list?
3. Write a function to merge two sorted linked lists into a single sorted linked list.
4. How would you find the middle element of a linked list in one pass?
5. How would you delete a node from a singly linked list without having access to the head node?
6. Write an algorithm to remove duplicates from an unsorted linked list.

𝗚𝗿𝗮𝗽𝗵𝘀

1. How do you represent a graph using an adjacency list and an adjacency matrix? Which one is more efficient for sparse graphs?
2. Explain Depth First Search (DFS) and Breadth First Search (BFS) and their time complexity.
3. Write an algorithm to detect a cycle in a directed graph.
4. How would you find the shortest path between two nodes in an unweighted graph?
5. Explain Dijkstra’s algorithm for finding the shortest path in a weighted graph.
6. How do you detect a cycle in an undirected graph?
5 changes: 5 additions & 0 deletions contributors/contributorsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2074,5 +2074,10 @@ contributors = [
fullname: "Yajnesh Kumar",
username: "https://github.com/yajneshkumar790",
},
{
id: 428,
fullname: "Krishna Negi",
username: "https://github.com/Krish1920",
},

];

0 comments on commit d617def

Please sign in to comment.