Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created May 15, 2024 09:54
Show Gist options
  • Save halitbatur/44a4222a3a72f8134b55c9d28aeacf49 to your computer and use it in GitHub Desktop.
Save halitbatur/44a4222a3a72f8134b55c9d28aeacf49 to your computer and use it in GitHub Desktop.
DSA Discussion

Discussion questions about DSA and Algorithims in Javascript

  1. Discuss the concept of recursion in programming. How does it work, and in what scenarios might recursion be more advantageous than iterative solutions?
  2. Explain the difference between time complexity and space complexity in algorithms. Why is it important to consider both when evaluating the efficiency of an algorithm?
  3. What distinguishes linear data structures from non-linear data structures? Provide examples and use cases where one might be preferred over the other.
  4. Discuss difference between linear and binary search
  5. In your own words explain the following data structures:
  • Linked List
  • Stack
  • Queues
@ImisebenziEmihle
Copy link

Room 3- Keketso, Emihle, Nhlanhla

  1. Recursion in programming is a method where a function calls itself repeatedly until it reaches a base case that stops the recursion. Recursion is particularly advantageous when dealing with problems that can be naturally broken down into smaller parts. examples of data strucutres that recursion works is in tree or graph traversal.

  2. Time complexity refers to the amount of time and algorithm it takes to complete the problem, and space complexity refers to the amount of memory it requires to solve a given problem.Making sure that an algorithm is both fast and doesn't use up too much memory is important, especially in places where there isn't a lot of space or when dealing with big sets of data. Algorithms often have tradeoffs between time and space complexity optimising one aspect while compromising the other.

  3. Linear - data strucutres where data is arranged linearly / sequentially where each an every element is attached to its previous and next adjacent.
    Non- linear : data strucutres where data elements are not arranged linearly/sequentially.

  4. Linear It defines a sequential search algorithm, and searches until it finds what its looking for. For binary search, a sorted array is divided into two, itworks by repeatedly dividing the search interval in half until the target element is found or the interval is empty.

  5. A linked list- A data structure in which sequence of notes are connected through pointers.
    Stack - A data strucutre that follows the last-in-first-out principle.
    Queues - A data structure that follows the first-in-first-out principle.

@PhamelaMhlaba
Copy link

Answers.

  1. It is a function that that calls itself repeatedly.

  2. Time Complexity- Refers to the amount of time it takes for the algorithm to complete its execution
    Space Complexity- The amount of memory that it uses during its execution
    We are trying to find a balance between the two and to pick the best algorithm for different situations.

  3. Linear data structures-It aligns data in a linear sequence, examples include arrays, lists or queues
    Non- linear data structure connects two or more information items, examples include a graph and a tree.

  4. Linear checks each element until it finds the element that it is looking for and the binary search it divides the list into half and searches for the element.

  5. Linked List- it is a series of nodes that are linked together through pointers.
    Stack- It is a data structure that uses the last in first out method where elements are added and
    removed from the top of the stack, allowing for efficient insertion and deletion operations.
    Queue- It is a data structure that uses that first in first out. You add elements to the end of the queue and you remove them the front.

Breakout room (Phamela, Letago, Vuyo, Koni)

@thewesss
Copy link

Group members: Tumelo, Lindokuhle, Wesley
1)Its a process whereby a function calls itself until a certain condition is met. scenarios that would be more advantageous would be is where readability is important, e.g. Tree structures
2)Time complexity is the amount time an algorithm takes to run its execution. Space complexity the amount of space it takes to execute a function.
3)linear data structures e.g.arrays,linked lists, stack follow a sequential order while non-linear data structures is more complex and have hierachical relationships
4)linear search:
5)

@samuelthis
Copy link

  1. Recursion is when the function is calling itself, it is also used to solve problems that contain smaller sub-problems. Moreover, Recursion is a programming technique where a function calls itself repeatedly until it reaches a base case that stops the recursion. In other words, a function solves a problem by breaking it down into smaller sub-problems of the same type, and then solving those sub-problems using the same function.
  2. Time complexity, is used to measure the amount of time required to execute the code. Space complexity, means the amount of space required to execute successfully the functionalities of the code. Both of the above complexities are measured with respect to the input parameters.
    3.Linear Data structure where data elements are arranged sequentially or linearly where each and every element is attached to its previous and next adjacent for example [list, array, stack and queue]. while Non-linear data structure, where data elements are not arranged sequentially or lineary example [map, graph and tree].
  3. In linear search input data need not to be in sorted. In binary search input data need to be in sorted order.
    • Linked List, is a collection of nodes, each containing a value and a reference to the next node. Each node is connected to its neighbors through pointers or references. Linked lists allow for efficient insertion and deletion of elements at any position.
  • Stack, A stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle.
  • Queues, foundational concept in computer science used for storing and managing data in a specific order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment