Algorithm Theories Flashcards

1
Q

Steps to solve programming problems

A
  1. Read the problem completely twice.
  2. Solve the problem manually with 3 sets of sample data.
  3. Optimize the manual steps.
  4. Write the manual steps as comments or pseudo-code.
  5. Replace the comments or pseudo-code with real code.
  6. Optimize the real code.

Solving Problems, Breaking it Down - Simple Programmer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an Algorithm?

A

Instructions (recipes) for completing a task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Time Complexity of Select Sort

A

Best: O(n^2)
Average: O(n^2)
Worst: O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Time Complexity of Quick Sort

A

Best: O(n log(n))
Average: O(n log(n))
Worst: O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Time Complexity of Merge Sort

A

Best: O(n log(n))
Average: O(n log(n))
Worst: O(n log(n))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Time Complexity of Bubble Sort

A

Best: O(n)
Average: O(n^2)
Worst: O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Space Complexity of Quick Sort

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Space Complexity of Merge Sort

A

O(n)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Space Complexity of Bubble Sort

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Space Complexity of Select Sort

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Space Complexity of Insertion Sort

A

O(1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Time Complexity of Insertion Sort

A

Best: O(n)
Average: O(n^2)
Worst: O(n^2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is data structure?

A

A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

List out the areas in which data structures are applied extensively?

A
  1. Compiler Design,
  2. Operating System,
  3. Database Management System,
  4. Statistical analysis package,
  5. Numerical Analysis,
  6. Graphics,
  7. Artificial Intelligence,
  8. Simulation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the major data structures used in the following areas : RDBMS, Network data model and Hierarchical data model.

A
  1. RDBMS = Array (i.e. Array of structures)
  2. Network data model = Graph
  3. Hierarchical data model = Trees
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the data structures used to perform recursion?

A

Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.

Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.

17
Q

De Morgan’s Laws

A
// Negation of conjunction
(!a && !b) == !(a || b)
// Negation of disjunction
(!a || !b) == !(a && b)

http://eddmann.com/posts/understanding-de-morgans-laws-to-simplify-propositions/