Data structure and algorithms Flashcards

1
Q

What is data structure

A

Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. For example, we have some data which has, player’s name “Pete” and age 26. Here “Pete” is of String data type and 26 is of integer data type.

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

What is algorithm?

A

An algorithm is a finite set of instructions or logic, written in order, to accomplish a certain predefined task. The algorithm is not the complete code or program, it is just the core logic(solution) of a problem, which can be expressed either as an informal high-level description as pseudocode or using a flowchart.

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

What properties must satisfy every algorithm?

A
  1. Input- There should be 0 or more inputs supplied externally to the algorithm.
  2. Output- There should be atleast 1 output obtained.
  3. Definiteness- Every step of the algorithm should be clear and well defined.
  4. Finiteness- The algorithm should have finite number of steps.
  5. Correctness- Every step of the algorithm must generate a correct output.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is measured performance of an algorithm?

A

An algorithm is said to be efficient and fast, if it takes less time to execute and consumes less memory space. The performance of an algorithm is measured on the basis of following properties :
Time Complexity
Space Complexity

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

What is space complexity in algorithms?

A

Its the amount of memory space required by the algorithm, during the course of its execution. Space complexity must be taken seriously for multi-user systems and in situations where limited memory is available.

An algorithm generally requires space for following components :
1.Instruction Space: Its the space required to store the executable version of the program. This space is fixed, but varies depending upon the number of lines of code in the program.

  1. Data Space: Its the space required to store all the constants and variables(including temporary variables) value.
  2. Environment Space: Its the space required to store the environment information needed to resume the suspended function.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is time complexity in algorithms?

A

Time Complexity is a way to represent the amount of time required by the program to run till its completion. It’s generally a good practice to try to keep the time required minimum, so that our algorithm completes it’s execution in the minimum time possible.

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