1. Home
  2. Explore
  3. Computer Science
  4. Programming Algorithms Explained

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Programming Algorithms Explained

  • 25Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Algorithmic Basics
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is the primary difference between different ways to write a function that produces the same numerical result?

Tap to flipClick to flipspace

The difference lies in the algorithm, which refers to the specific steps used to complete the computation.

Or swipe the card

25 cards

  1. What is the primary difference between different ways to write a function that produces the same numerical result?

    The difference lies in the algorithm, which refers to the specific steps used to complete the computation.

  2. What factors are generally considered when evaluating the 'goodness' of an algorithm?

    Generally, the fewer steps an algorithm takes, the better it is. Other factors, like how much memory it uses, are also considered.

  3. From whom does the term 'algorithm' originate?

    The term 'algorithm' comes from the Persian polymath Muḥammad ibn Mūsā al-Khwārizmī, one of the fathers of algebra.

  4. What is an 'array' in the context of computer science?

    An array is a series of items, such as numbers or names, represented in memory.

  5. Describe the first step of the Selection Sort algorithm when sorting an array in ascending order.

    The first step is to scan down the entire array to find the smallest number.

  6. After finding the smallest number in an array using Selection Sort, what is the next action?

    The smallest number is swapped with the number in the top (first) location of the unsorted portion of the array.

  7. How does Selection Sort proceed after placing the first smallest number in its correct position?

    The process repeats, but instead of starting at the top, it starts one spot below the last sorted position, finding the next smallest number in the remaining unsorted part.

  8. What kind of loop structure is characteristic of Selection Sort's pseudo-code?

    Selection Sort typically uses one FOR loop nested inside another FOR loop.

  9. What is the computational complexity of Selection Sort, expressed in big O notation?

    The computational complexity of Selection Sort is roughly N2N^2N2 (N squared), written as O(N2)O(N^2)O(N2).

  10. Why is an O(N2)O(N^2)O(N2) algorithm like Selection Sort considered inefficient for large datasets?

    An O(N2)O(N^2)O(N2) algorithm is inefficient because if the input size (N) increases by a factor of X, the running time increases by a factor of X2X^2X2. For example, a 10-fold increase in N leads to a 100-fold increase in running time.

  11. What is the first step of the Merge Sort algorithm when sorting an array?

    The first step is to check if the size of the array is greater than 1. If it is, the array is split into two halves.

  12. When does the 'merge' process begin in Merge Sort?

    The merge process begins when the array has been recursively split into individual arrays, each containing only one item.

  13. Describe the merging step in Merge Sort when combining two sorted arrays.

    When merging two individually sorted arrays, the algorithm compares the first numbers in each array, takes the lowest one, and adds it to a new combined array. This process repeats until all numbers are merged.

  14. What is the computational complexity of Merge Sort, expressed in big O notation?

    The computational complexity of Merge Sort is N×Log NN \times \text{Log} \ NN×Log N, written as O(NLog N)O(N \text{Log} \ N)O(NLog N).

  15. Why is Merge Sort generally considered more efficient than Selection Sort?

    Merge Sort is more efficient because its complexity is O(NLog N)O(N \text{Log} \ N)O(NLog N), which scales much better than O(N2)O(N^2)O(N2) for large N. Doubling the input size only adds one split step, for example.

  16. What is a 'graph' in the context of computer science?

    A graph is a network of nodes (like cities) connected by lines (like roads).

  17. What is meant by 'cost' or 'weight' in a graph problem?

    Each line (edge) in a graph can be labeled with a 'cost' or 'weight', which represents a value like time, distance, or effort to traverse that connection.

  18. What is a 'brute force' approach to solving a graph search problem?

    A brute force approach involves trying every single possible path exhaustively and calculating the total cost of each to find the optimal one.

  19. Who invented the classic algorithmic solution to the shortest path problem in graphs?

    The classic algorithmic solution to this graph problem was invented by Edsger Dijkstra, and it's named Dijkstra's algorithm.

  20. How does Dijkstra's algorithm initialize costs for nodes at the start?

    It starts the source node with a cost of 0 and marks all other connecting nodes with question marks, as their costs are unknown initially.

  21. What is the primary rule Dijkstra's algorithm follows when choosing the next node to explore?

    Dijkstra's algorithm always starts with or proceeds to explore from the node with the lowest known cost.

  22. When does Dijkstra's algorithm update the cost to a connecting node?

    It updates the cost to a connecting node if a newly found path, through the current node, results in a lower total cost than any previously recorded path to that connecting node.

  23. What was the initial computational complexity of Dijkstra's original algorithm?

    Dijkstra's original algorithm had a complexity of the number of nodes in the graph squared, or O(N2)O(N^2)O(N2).

  24. How was Dijkstra's algorithm improved in terms of computational complexity?

    Dijkstra's algorithm was improved to a complexity of N×Log N+EN \times \text{Log} \ N + EN×Log N+E, where N is the number of nodes and E is the number of lines (edges).

  25. Where are algorithms like Dijkstra's algorithm commonly used in the modern world?

    Algorithms like Dijkstra's are commonly used in services like Google Maps to find directions and calculate the best routes.

Card 1 of 25
Card 1 of 25

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent