/Geeks_DSA

About This is my personal GitHub repository where I share my personal projects, experiments, and ideas. I use this space to explore new technologies, collaborate with other developers, and showcase my skills

Primary LanguageJavaScript

Q.1 : What is Data Structure ?

  • Data Structure is a way to orgainzing the data so that the data can used effectiently manners. There are different Kinds of Data Structure with different kinds of implimentations. For Example Binery Search, Hashmap, Array, Linked List, Binery Tree Etc.

Q.2 : What is Linear and Non - Linear Data Structure?

  • Linear Data Structure : Linear Data Structure is nothing but when the elements are in sequence or Linear List then that data structure is called Linear Data Structure.

  • Example : Array, Linked List, Stack & Queue etc.

  • Non Linear Data Structure : A Data Structure is said to be Non-Linear if the transversal of nodes is Non-Linear in nature.

  • Example : Graph & Trees

Q.3. What are the various operations that can be performed on different Data Structures?

  • Insertion : Add a new data item in the given collection of data items.

  • Deletion : Delete an existing data item from the given collection of data items.

  • Traversal : Access each data item exactly once so that it can be processed.

  • Searching : Find out the location of the data item if it exists in the given collection of data items.

  • Sorting : Arranging the data items in some order i.e. in ascending or descending order in case of numerical data and in dictionary order in case of alphanumeric data.

Q. 4 What is Algorithm?

  • Algorithm is a Step by Step Procedure, which defines the set of instruction to be execute in a certain order to get the desirable output.

Q.5 Why we need algorithm Analysis?

  • Alogrithm analysis into two factor i.e. Time & Space. Means That how much time getting for execution the code and how much require space to run the algorithm.

Q.6 What is Linked List & Types of its?

  • Linked List is a linear Data structure where each element is in seprated object. Each element of a list have two things i.e. The Data , Reference of the Next Node.

  • Singly Linked List : Every node stores the address or reference of the next node. The last node is has address as null. i.e. 1 -> 2 -> 3 -> 4 -> null

  • Doubly Linked List : Doubly linked list is a complex type of linked list in which a node contains a pointer to the previous as well as the next node in the sequence.

  • Circuler Linked List : All Nodes connected in the form of Circuler. There is no null at the end.

Q.7 : What is Stack ?

  • Stack is abstract Data Structure, used to store the reitrative values in Last in Last Out method.

Q.8. What is Queue?

  • Queue is abstracted Data Strucutre. It open in both the points in starting and ending. It is used to store the reitrative values in First in First Out Manners.

Q.9 What is Selection Sort?

  • Selection Sort is a technique which is used to sorting the list. First it selecting the smallest element from the unsorted list and moving it to the sortind list. The algorithm repedily selected the smallest element from the unsorted portion of the list and swap it with the first element of the unsorted portion. The process is continuosly working in same manner while whole list is not sorted.

Q.10 What is bubble sort?

  • Bubble Sort is a simplest sorting algorithm that works by repidly swapping the adjucent element if they are in wrong order. This algorithm is not applicable for the large data if the worse cases the time complexity is very high.

Q.11 What is hashing?

  • Hashing is a technique to convert a range of key values into a range of indexes of an array. By using hash tables, we can create an associative data storage where data index can be find by providing its key values.

Q.12 What is Recursion?

  • Recursion is a process in which the function calling itself direct or indirectly. This is called recursion. And the currosponding function is called recursion functions.

Q.13 What is Base Case?

  • When Conditions terminate the scenerios. On that time that case we call the base case.

Q.14 What is Array?

  • Array is a collection of items of same data type sorted at continuous memory locations.

Q.15 What is string?

  • A string is a data type used in programming, that is used to represent text rather than numbers.

Q.16 What is Multidimentional Array?

  • A multidimensional array is a multidimensional array with more than one dimension. It is an array of arrays or an array with numerous layers. It refers the matrix or a table in the form of rows and columns.

Q.17 What is Enque()?

  • enqueue() adds an element to the end of the queue

Q.18 What is Dequeue()?

  • dequeue() removes an element from the front of the queue

Q.19 What is Push and Pop?

  • Push - It is used for adding the element in the array at the end.
  • Pop - It is used for removing the element in the array at the end.

Q.20 What is Loop in Javascript?

  • Loops are used in JavaScript to perform repeated tasks based on a condition. Conditions typically return true or false . A loop will continue running until the defined condition returns false .

Q.21. Is Recursion is an Algoritim ?

  • Yes, Recursion is an Algoritim because the fuction is calling itself by the direct or indirect.

Q.22. What are the time compexity of the basis Queue operations (enque, dequeue, Peek) ?

  • O(1);

Q.23. What are the time compexity of the basis Stack operations (push, pop, top) ?

  • O(1);

Q.24. What do you understand by the Binery Search?

  • Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item, until you've narrowed down the possible locations to just one.

Q.25. What are some common uses for 2 D Arrays in Programming?

  • Using 2d arrays, you can store so much data at one moment, which can be passed at any number of functions whenever required.

Q.26. What are the benefits and limitation of using Two Pointer Technique?

Q.27. How would you impliment an algoritim for solving the knapsack Problem? What is the Time complexity of this algoritim?

Q.28. Difference between Stack and Queue?

  • Stack :
  1. A stack is a data structure that stores a collection of elements, with operations to push (add) and pop (remove) elements from the top of the stack.

  2. Stacks are based on the LIFO principle, i.e., the element inserted at the last, is the first element to come out of the list.

  3. Insertion and deletion in stacks takes place only from one end of the list called the top.

  4. Stack does not have any types.

  • Queue :
  1. A queue is a data structure that stores a collection of elements, with operations to enqueue (add) elements at the back of the queue, and dequeue (remove) elements from the front of the queue.

  2. Queues are based on the FIFO principle, i.e., the element inserted at the first, is the first element to come out of the list.

  3. Insertion and deletion in queues takes place from the opposite ends of the list. The insertion takes place at the rear of the list and the deletion takes place from the front of the list.

  4. Queue is of three types – 1. Circular Queue 2. Priority queue 3. double-ended queue.

Q.29. What is Insertion Sort?

  • Insertion sort is a sorting algorithm in which the elements are transferred one at a time to the right position. In other words, an insertion sort helps in building the final sorted list, one item at a time, with the movement of higher-ranked elements. An insertion sort has the benefits of simplicity and low overhead.

Q.30. Difference between Data Structure and Algoritim?

  • Data Structure :
  1. Defination : The way data is organized, stored, and retrieved
  2. Perpose : Provides an efficient way to organize and store data for easy retrieval and modification
  3. Operations : Insertion, Deletion, Search, Update, Traverse, etc.
  4. Examples : Array, Linked List, Stack, Queue, Tree, Graph, Hash Table, etc.
  • Algoritim :
  1. Defination : A set of instructions used to solve a specific problem or perform a specific task

  2. Perpose : Provides a systematic approach to solving problems by breaking them down into smaller, more manageable steps

  3. Operations : Sorting, Searching, Optimization, Pathfinding, etc.

  4. Examples : Sorting, Searching, Graph Traversal, Dynamic Programming, Divide and Conquer, etc.

Q.31. How does Dequeue Differs from Queue?

  • The operations allowed in the queue are:
  1. insert an element at the rear
  2. delete element from the front
  3. get the last element
  4. get the first element
  5. check the size of the queue
  6. check if the queue is empty or not
  • The operations allowed in deque are:
  1. insert an element at the back
  2. Insert an element at the front
  3. delete the element at the back
  4. delete the element from the front
  5. get the last element
  6. get the first element
  7. check the size of the deque
  8. check if the deque is empty or not

Q.32. How does memoization improve the performance of a recursive function?

  • Memoization is a way to potentially make functions that use recursion run faster. As I'll show in an example below, a recursive function might end up performing the same calculation with the same input multiple times.