CS 204 – DS and Algorithms Classroom Policy ▪ Class Time ▪ Absences ▪ Submissions ▪ Exams
What is a data? - data is any information that can be stored, processed, or transmitted by a computer. - It can be numbers, text, images, or any other form of information that can be represented digitally.
Characteristics of data 1. Accuracy - should represent real-world values or information correctly and precisely 2. Consistency - Data should remain uniform across different systems or applications, avoiding contradictions (e.g., a person’s age should match their date of birth).
Characteristics of data 3.Timeliness - Data should be current and up-to-date to maintain its relevance for decision-making or processing. 4. Completeness - it should contain all required information without missing values or gaps 5. Relevance - It should be applicable and useful for its intended purpose or context.
Characteristics of data 6. Reliability - it should come from reliable source and dependable for accurate results 7. Validity - conform to the expected format, rules, or ranges. Ex. E-mail should contain “@” and a domain 8. Accessibility – available and easy to retrieve or used by authorized users or systems
Characteristics of data 9. Volatility - some data is temporary and subject to change (volatile) while other data remain stable over time (non-volatile) 10. Granularity - data can be detailed or summarized based on the level of detail required.
What is an algorithm? - An algorithm is a step-by-step process to solve a problem, where each step indicates an intermediate task. - It contain finite number of steps that leads to the solution of the problem
What are the properties/characteristics of an algorithm? 1. Input-Output – an algorithm takes ‘0’ or more input and produces the required output. 2. Finiteness – an algorithm must terminate in countable number of steps 3. Definiteness – each step of an algorithm must be stated clearly and unambiguously.
What are the properties/characteristics of an algorithm? 4. Effectiveness – each and every step in an algorithm can be converted into a programming language statement. 5. Generality – algorithm is generalized one. It works on all set of inputs and provides the required output. (not restricted to a single input value.)
Categories of Algorithm: ▪ Sequence – performed successively one by one without skipping any step. The sequence should be simple and easy to understand. Each instruction of such algorithm is executed, because no selection or conditional branching exists.
Example of sequence statement //adding two numbers Step 1: start Step 2: read a,b Step 3: sum=a+b Step 4: write sum Step 5: stop
Categories of Algorithm: ▪ Selection - In order to solve the problem which involve decision making or option selection using the format: if (condition) Statement-1; else Statement-2;
if (condition) Statement-1; else Statement-2; **it specifies if the statement is TRUE, statement-1 will be executed, otherwise, statement- 2 will be executed.**
Example of selection statement //person eligibility to vote Step 1: start Step 2: read age Step 3: if age>=18 then step_4 else step_5 Step 4:write ”person is eligible to vote” Step 5: write “person is not eligible to vote” Step 6: stop
Example of selection statement //biggest among two numbers Step 1: start Step 2: read a,b Step 3: if a>b then Step 4:write ”a is greater than b” Step 5: write “b is greater than a” Step 6: stop
Categories of Algorithm: ▪ Iteration - type of algorithm that is used in solving problems in which involves repetition of statement. A particular number of statements are repeated n number of times.
How to write an algorithm? ▪ There are no well-defined standards for writing algorithms ▪ It is problem and resource dependent. ▪ Never written to support a particular programming code ▪ Know the problem domain for which you are designing a solution.
Why analysis of algorithm? ▪ Algorithm analysis helps us to determine which algorithm is most efficient in terms of time and space consumed. ▪ The goal of the analysis of algorithms is to compare algorithms (or solutions) mainly in terms of running time but also in terms of other factors (e.g., memory, developer effort, etc.)
What is Running Time Analysis? ▪ It is the process of determining how processing time increases as the size of the problem (input size) increases. ▪ Input size is the number of elements in the input, and depending on the problem type, the input may be of different types.
The following are the common types of inputs. ▪ Size of an array ▪ Polynomial degree ▪ Number of elements in a matrix ▪ Number of bits in the binary representation of the input ▪ Vertices and edges in a graph
How to compare algorithms? ▪ Computing the running time Affected by: 1. input size 2. machine type 3. programming style
What is a program ▪ a program is a specific set of ordered operations for a computer to perform. ▪ In the modern computer that John von Neumann outlined in 1945, the program contains a one-at-a-time sequence of instructions that the computer follows.
Characteristics of a program 1. Flexibility- should be written in such a manner that it allows one to add new features without changing the existing module 2. User-friendly - it's a technical solution that is easy for all (or at least most) people to use to get their jobs done. 3. Portability - it can be used in an operating systems other than the one in which it was created without requiring major rework.
Characteristics of a program 4. Reliability - the probability of failure-free operation of a computer program for a specified period in a specified environment. Reliability is a customer-oriented view of software quality. 5. Self-documenting code - code that doesn't require code comments for human to understand its naming conventions and what it is doing. It utilizes descriptive method and variable names that resemble human speech.
Data Structure - A data structure is a special format for storing and organizing data. - General data structure types include arrays, files, linked lists, stacks, queues, graphs and so on. Characteristics of Data Structure 1. Correctness - should accurately implement its interface 2. Time Complexity - The running time or execution time of data structure operations must be as short as feasible. ▪ Best Case ▪ Worst Case
Data Structure 3. Space Complexity - refers to the total amount of memory space used by an algorithm/program, including the space of input values for execution. Calculate the space occupied by variables in an algorithm/program to determine space complexity. The best algorithm/program should have a low level of space complexity
Assignment#3 Make a simplest algorithm for the following and be able to explain it in class. 1. Create an algorithm that will generate the first 10 even numbers and display the sum of it. 2. Create an algorithm that will input two numbers and display the sum, difference, product and quotient. 3. Create an algorithm that will determine if the number is divisible by 2, it will display a message “divisible by 2”, otherwise, “not divisible by 2” will be displayed.

lecture on preliminary on data structore

  • 1.
    CS 204 –DS and Algorithms Classroom Policy ▪ Class Time ▪ Absences ▪ Submissions ▪ Exams
  • 2.
    What is adata? - data is any information that can be stored, processed, or transmitted by a computer. - It can be numbers, text, images, or any other form of information that can be represented digitally.
  • 3.
    Characteristics of data 1.Accuracy - should represent real-world values or information correctly and precisely 2. Consistency - Data should remain uniform across different systems or applications, avoiding contradictions (e.g., a person’s age should match their date of birth).
  • 4.
    Characteristics of data 3.Timeliness- Data should be current and up-to-date to maintain its relevance for decision-making or processing. 4. Completeness - it should contain all required information without missing values or gaps 5. Relevance - It should be applicable and useful for its intended purpose or context.
  • 5.
    Characteristics of data 6.Reliability - it should come from reliable source and dependable for accurate results 7. Validity - conform to the expected format, rules, or ranges. Ex. E-mail should contain “@” and a domain 8. Accessibility – available and easy to retrieve or used by authorized users or systems
  • 6.
    Characteristics of data 9.Volatility - some data is temporary and subject to change (volatile) while other data remain stable over time (non-volatile) 10. Granularity - data can be detailed or summarized based on the level of detail required.
  • 7.
    What is analgorithm? - An algorithm is a step-by-step process to solve a problem, where each step indicates an intermediate task. - It contain finite number of steps that leads to the solution of the problem
  • 8.
    What are theproperties/characteristics of an algorithm? 1. Input-Output – an algorithm takes ‘0’ or more input and produces the required output. 2. Finiteness – an algorithm must terminate in countable number of steps 3. Definiteness – each step of an algorithm must be stated clearly and unambiguously.
  • 9.
    What are theproperties/characteristics of an algorithm? 4. Effectiveness – each and every step in an algorithm can be converted into a programming language statement. 5. Generality – algorithm is generalized one. It works on all set of inputs and provides the required output. (not restricted to a single input value.)
  • 10.
    Categories of Algorithm: ▪Sequence – performed successively one by one without skipping any step. The sequence should be simple and easy to understand. Each instruction of such algorithm is executed, because no selection or conditional branching exists.
  • 11.
    Example of sequencestatement //adding two numbers Step 1: start Step 2: read a,b Step 3: sum=a+b Step 4: write sum Step 5: stop
  • 12.
    Categories of Algorithm: ▪Selection - In order to solve the problem which involve decision making or option selection using the format: if (condition) Statement-1; else Statement-2;
  • 13.
    if (condition) Statement-1; else Statement-2; **it specifiesif the statement is TRUE, statement-1 will be executed, otherwise, statement- 2 will be executed.**
  • 14.
    Example of selectionstatement //person eligibility to vote Step 1: start Step 2: read age Step 3: if age>=18 then step_4 else step_5 Step 4:write ”person is eligible to vote” Step 5: write “person is not eligible to vote” Step 6: stop
  • 15.
    Example of selectionstatement //biggest among two numbers Step 1: start Step 2: read a,b Step 3: if a>b then Step 4:write ”a is greater than b” Step 5: write “b is greater than a” Step 6: stop
  • 16.
    Categories of Algorithm: ▪Iteration - type of algorithm that is used in solving problems in which involves repetition of statement. A particular number of statements are repeated n number of times.
  • 17.
    How to writean algorithm? ▪ There are no well-defined standards for writing algorithms ▪ It is problem and resource dependent. ▪ Never written to support a particular programming code ▪ Know the problem domain for which you are designing a solution.
  • 18.
    Why analysis ofalgorithm? ▪ Algorithm analysis helps us to determine which algorithm is most efficient in terms of time and space consumed. ▪ The goal of the analysis of algorithms is to compare algorithms (or solutions) mainly in terms of running time but also in terms of other factors (e.g., memory, developer effort, etc.)
  • 19.
    What is RunningTime Analysis? ▪ It is the process of determining how processing time increases as the size of the problem (input size) increases. ▪ Input size is the number of elements in the input, and depending on the problem type, the input may be of different types.
  • 20.
    The following arethe common types of inputs. ▪ Size of an array ▪ Polynomial degree ▪ Number of elements in a matrix ▪ Number of bits in the binary representation of the input ▪ Vertices and edges in a graph
  • 21.
    How to comparealgorithms? ▪ Computing the running time Affected by: 1. input size 2. machine type 3. programming style
  • 22.
    What is aprogram ▪ a program is a specific set of ordered operations for a computer to perform. ▪ In the modern computer that John von Neumann outlined in 1945, the program contains a one-at-a-time sequence of instructions that the computer follows.
  • 23.
    Characteristics of aprogram 1. Flexibility- should be written in such a manner that it allows one to add new features without changing the existing module 2. User-friendly - it's a technical solution that is easy for all (or at least most) people to use to get their jobs done. 3. Portability - it can be used in an operating systems other than the one in which it was created without requiring major rework.
  • 24.
    Characteristics of aprogram 4. Reliability - the probability of failure-free operation of a computer program for a specified period in a specified environment. Reliability is a customer-oriented view of software quality. 5. Self-documenting code - code that doesn't require code comments for human to understand its naming conventions and what it is doing. It utilizes descriptive method and variable names that resemble human speech.
  • 25.
    Data Structure - Adata structure is a special format for storing and organizing data. - General data structure types include arrays, files, linked lists, stacks, queues, graphs and so on. Characteristics of Data Structure 1. Correctness - should accurately implement its interface 2. Time Complexity - The running time or execution time of data structure operations must be as short as feasible. ▪ Best Case ▪ Worst Case
  • 26.
    Data Structure 3. SpaceComplexity - refers to the total amount of memory space used by an algorithm/program, including the space of input values for execution. Calculate the space occupied by variables in an algorithm/program to determine space complexity. The best algorithm/program should have a low level of space complexity
  • 27.
    Assignment#3 Make a simplestalgorithm for the following and be able to explain it in class. 1. Create an algorithm that will generate the first 10 even numbers and display the sum of it. 2. Create an algorithm that will input two numbers and display the sum, difference, product and quotient. 3. Create an algorithm that will determine if the number is divisible by 2, it will display a message “divisible by 2”, otherwise, “not divisible by 2” will be displayed.