0% found this document useful (0 votes)
8 views4 pages

2 Markss

The document outlines the qualities of a good algorithm, including correctness, efficiency, and finiteness, as well as strategies for algorithm development such as brute force and dynamic programming. It also discusses Python data types, features of lists, the concept of string immutability, and the advantages of tuples over lists. Additionally, it defines modules and packages in Python and lists common exception types.

Uploaded by

sudhar170683
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

2 Markss

The document outlines the qualities of a good algorithm, including correctness, efficiency, and finiteness, as well as strategies for algorithm development such as brute force and dynamic programming. It also discusses Python data types, features of lists, the concept of string immutability, and the advantages of tuples over lists. Additionally, it defines modules and packages in Python and lists common exception types.

Uploaded by

sudhar170683
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1.State the qualities of good algorithm.

(explain any three)


1. Correctness:
The algorithm should solve the problem it is designed for and produce the correct
output for all possible inputs.
2. Efficiency:
The algorithm should make optimal use of resources, especially time and space.
This is often measured in terms of time complexity (how quickly it runs) and space
complexity (how much memory it uses).
3. Finiteness:
The algorithm should terminate after a finite number of steps. It should not run
indefinitely.
4. Clarity:
The steps of the algorithm should be clearly defined, easy to understand, and
follow a logical sequence. This ensures that it can be implemented correctly.
5. Generality:
The algorithm should work for a wide range of input cases, not just for specific
examples. It should be flexible enough to handle variations of the problem.
6. Scalability:
A good algorithm should handle increasing input sizes gracefully. As the size of the
problem grows, the algorithm should still function efficiently (i.e., have good
asymptotic performance).
7. Simplicity:
The algorithm should be as simple as possible while still being effective. Overly
complex algorithms can be harder to debug, test, and maintain.
8. Determinism:
The algorithm should behave predictably. For the same input, it should always
produce the same output.
9. Maintainability:
The algorithm should be easy to maintain, modify, or extend if necessary. Good
documentation and modular design can improve maintainability.
10. Adaptability:
The algorithm should be adaptable to changing requirements or conditions,
allowing for improvements or adjustments as needed.
2.Enumerate the strategies involved in developing algorithm.
✓ Brute Force
✓ Divide and Conquer
✓ Greedy Approach
✓ Dynamic Programming (DP)
✓ Backtracking
✓ Constraint Satisfaction
3.List the various single valued data types in Python
✓ Integer (int)
✓ Floating Point (float)
✓ Complex (complex)
✓ Boolean (bool)
✓ String (str)
4.Mention the features of lists in python.
✓ Ordered
✓ Mutable
✓ Dynamic
✓ Heterogeneous
✓ Indexed
✓ Slicing
✓ Iterable
5.Compare return value and composition
Aspect Return Value Composition
Definition The value returned by a function. A design principle in OOP
where objects are composed
of other objects.
Purpose To provide output from a function. To create complex objects
using simpler, reusable
components.
Context Used in functions and methods to return data. Primarily used in
object-oriented design to
model relationships between
objects.
Usage Returned after function execution. Objects are created by
combining other objects.
Example return 42 or return some object in a function. A Car class composed
of an Engine class.
6.Define string immutability
String immutability refers to the property of strings in many programming
languages, including Python, where once a string is created, it cannot be modified.
This means that any operation that seems to modify a string, such as changing a
character or appending new content, actually creates a new string instead of
altering the original string.
7.What is range () function and how it is used in lists?
The range() function in Python is a built-in function used to generate a sequence of
numbers. It is commonly used in loops (like for loops) for iterating over a specific
range of values. While it is primarily used in loops, it can also be used in
conjunction with lists, especially when you need to create a list of numbers or
manipulate the elements within a list.
Using range() with Lists:
While range() itself returns a range object (which is an iterable), it can be used in
lists in the following ways:
✓ Creating a List of Numbers
✓ Modifying List Elements Using range()
✓ Extracting Specific Elements from a List
✓ Nested Loops with range() for List Operations
8.What are the advantages of “Tuple” over “List”?
✓ Immutability
✓ Performance (Faster)
✓ Memory Efficiency
✓ Hashability
✓ Semantic Meaning (Use Case)
✓ Safety
✓ Tuple Packing and Unpacking
✓ Less Overhead
9.What is module and package in Python?
In Python, modules and packages are fundamental concepts used for organizing
and structuring code. They help in managing large codebases, enabling reusability,
and simplifying the development process.
10.List few common exception types.
✓ SyntaxError Incorrect syntax in code.
✓ IndentationError Incorrect indentation.
✓ TypeError Operation applied to an inappropriate data type.
✓ ValueError Argument is of the correct type but has an invalid value.
✓ IndexError List index out of range.
✓ KeyError Dictionary key not found.
✓ FileNotFoundError File not found when trying to open it.

You might also like