Followers

Friday 10 April 2020

Pseudocode and Abstract data types : Lecture 1


Department: MCA
Semester    : II
Subject       : Data Structures through C++
Paper          : CCMCA 203
Faculty       : Avinash Kumar



                                      Syllabus covered in  this blog:
                                     Pseudo code, Abstract Data Type



Pseudocode:
Definition: Pseudocode is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations. It is used for creating an outline or a rough draft of a program. Pseudocode summarizes a program’s flow, but excludes underlying details. System designers write pseudocode to ensure that programmers understand a software project's requirements and align code accordingly.

Description: Pseudocode is not an actual programming language. So it cannot be compiled into an executable program. It uses short terms or simple English language syntaxes to write code for programs before it is actually converted into a specific programming language.
This is done to identify top level flow errors, and understand the programming data flows that the final program is going to use. This definitely helps save time during actual programming as conceptual errors have been already corrected.
Firstly, program description and functionality is gathered and then pseudocode is used to create statements to achieve the required results for a program. Detailed pseudocode is inspected and verified by the designer’s team or programmers to match design specifications.
Catching errors or wrong program flow at the pseudocode stage is beneficial for development as it is less costly than catching them later. Once the pseudocode is accepted by the team, it is rewritten using the vocabulary and syntax of a programming language.
The purpose of using pseudocode is an efficient key principle of an algorithm. It is used in planning an algorithm with sketching out the structure of the program before the actual coding takes place.

Advantages of pseudocode:

  • Improves the readability of any approach. It’s one of the best approaches to start implementation of an algorithm.
  • Acts as a bridge between the program and the algorithm or flowchart. Also works as a rough documentation, so the program of one developer can be understood easily when a pseudo code is written out. In industries, the approach of documentation is essential. And that’s where a pseudo-code proves vital.
  • The main goal of a pseudo code is to explain what exactly each line of a program should do, hence making the code construction phase easier for the programmer.
  •  
  • Example, C++ code :
  •  if (i < 10)
  • {                                   à                   Pseudocode
  •    i++;                                       if i is less than 10, increment i by 1
  • }                                              

How to write a Pseudo-code?

  1. Arrange the sequence of tasks and write the pseudocode accordingly.
  2. Start with the statement of a pseudo code which establishes the main goal or the aim.
  3. The way the if-else, for, while loops are indented in a program, indent the statements likewise, as it helps to comprehend the decision control and execution mechanism.
  4. Use appropriate naming conventions. The human tendency follows the approach to follow what we see. If a programmer goes through a pseudo code, his approach will be the same as per it, so the naming must be simple and distinct.
  5. Use appropriate sentence casings, such as CamelCase for methods, upper case for constants and lower case for variables.
  6. Elaborate everything which is going to happen in the actual code. Don’t make the pseudo code abstract.
  7. Use standard programming structures such as ‘if-then’, ‘for’, ‘while’, ‘cases’ the way we use it in programming.
  8. Check whether all the sections of a pseudo code is complete, finite and clear to understand and comprehend.
  9. Don’t write the pseudo code in a complete programmatic manner. It is necessary to be simple to understand even for a layman or client, hence don’t incorporate too many technical terms.

Abstract Data Types

Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of value and a set of operations.
The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. It does not specify how data will be organized in memory and what algorithms will be used for implementing the operations. It is called “abstract” because it gives an implementation-independent view. The process of providing only the essentials and hiding the details is known as abstraction.
  
The user of data type does not need to know how that data type is implemented, for example, we have been using Primitive values like int, float, char data types only with the knowledge that these data type can operate and be performed on without any idea of how they are implemented. Hence a user only needs to know what a data type can do, but not how it will be implemented.
Examples of Abstract Data Types:
·         arrays
·         two-dimensional arrays
·         stack
·         queue
·         linked list
·         tree
·         binary tree
·         collections

·         lists

1 comment:

  1. Thks sir, its good to see you. You are carrying about our stuy like a guardian

    ReplyDelete