Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Example of Algorithms, Assignments of Digital Communication Systems

An introduction to algorithms, pseudocode, and developing an application using Python programming language. It explains the divide and conquer algorithm, recursion, and the process of creating an application. It also discusses the importance of formulating requirements, precise specifications, creating a design, coding, testing the program, and maintenance. useful for computer science students who want to learn about algorithms and programming languages.

Typology: Assignments

2020/2021

Available from 07/20/2022

lusssh
lusssh 🇬🇧

2 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
FROM ALGORITHM TO CODE
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Example of Algorithms and more Assignments Digital Communication Systems in PDF only on Docsity!

FROM ALGORITHM TO CODE

Contents

    1. Algorithms
    • 1.1. Euclid’s algorithm
    • 1.2. Divide and Conquer: Merge Sort
    1. Pseudocode
    • 2.1. Pseudocode of GCD algorithm:
    • 2.2. Pseudocode of divide-and-conquer algorithm:
  • 3 Developing an application
    • 3.1. Formulate Requirements
    • 3.2. Precise Specifications
    • 3.3. Create a Design
    • 3.4. Coding
    • 3.5. Test the Program.....................................................................................................................
    • 3.6. Maintenance
    1. Python – programming language
  • Bibliography

If one of the list runs out of elements, we will add in the merged list the rest of the elements from the other list. Fig 1.2 – Merge-sort algorithm flowchart Now, suppose we have an unordered list. To sort it, we can use divide-and-conquer algorithm:

  • split the list in two(halving the initial list)
  • sorting the first list
  • sorting the second list
  • merging the lists back into original list

These steps look easy enough. The main problem is, how we can sort the two halves? The solution is to create a function that will call by itself (basically halving the list on and on) until the list will have only one single element (which will be sorted). This is called recursion!!! Fig 1.2.1 – Divide and conquer – sorting flowchart

2. Pseudocode

The computer can only do exactly what the program tells the computer to do. The process for creating an application is often broken down into stages:

3.1. Formulate Requirements : You have to really know the problem, before starting to

solve it.

3.2. Precise Specifications Focus on what your program will accomplish, instead of how

your program will work. Describing the inputs and outputs used in the program, specifying the relationship between them.

3.3. Create a Design Design the structure of the program. Here, you work out the

program. Design the algorithm that will meet the criteria in specifications.

3.4. Coding Translate the design into a computer language(we will use Python) and put

it into the computer.

3.5. Test the Program Testing the app to see if is working correctly. If there are any

errors (bugs), they should be fixed before going further. When you try to fix the errors is called debugging.

3.6. Maintenance keep developing the program, responding to user needs. Most of the

programs are evolving over the years.

4. Python – programming language

A programming language represents the code to write down the instructions which computers can follow. The process of writing an algorithm in a programming language is called coding. With the help of the programming languages, we can write code than is easier for humans to understand. Programming languages have a precise form (syntax) and a precise meaning (semantics). The language that computer ‘speak’ is called binary. Being very difficult for humans to read/write in binary, an intermediate language had to be developed to translate in binary our code – this is the interpreter. Python is a object-oriented programming language, widely-used, with dynamic semantics, used for general-purpose programming. It was created by Guido van Rossum, and first released on February 20, 1991. When a programmer is using a high-level language to develop programs (python for example), the computer needs to understand the code – the interpreter – interprets the code into bytes. So, the programmer generates source code and the interpreter generates object code ( P-Code, binary code or machine code) (Zelle, 2002). Fig. 4 – Basic program flowchart

A compiler reads the program and translates it completely before the program starts running. To generate object code from source code, there are two different techniques used

  • using the compiler or the interpreter. Compilers produce object code that could be run on its own (an executable file) whereas an interpreter had to be present to run its program as it went along (Zelle, 2002) An Integrated Development Environment (IDE) is like a GUI (graphical interface) with windows and menus, used to facilitate writing the code, run it and debug it. The next two programs are written using visual studio (IDE), in python programming language: Sorting a list using divide-and-conquer algorithm

The Euclidean algorithm is one of the fastest way of finding the GCD on any large integer!!!

Bibliography

Anon., n.d. Intro to algorithms. [Online] Available at: https://www.khanacademy.org/computing/computer-science/algorithms/intro-to- algorithms/v/what-are-algorithms [Accessed 18 10 2021]. Downey, A. B., 2009. PYTHON FOR SOFTWARE DESIGN. New York: Cambridge University Press. Gauld, A., 2006. Learning to program. s.l.:Addison-Wesley Professional. Sweigart, A., 2015. Cracking codes with python. San Francisco: William Pollock. Zelle, J. M., 2002. Python Programming: An Introduction to Computer Science. 1st ed. s.l.: Wartburg College.