SlideServe
Menu
Préférences
© SlideServe · v2026

Overview of Programming Languages and Algorithms

gonser avatar
24 diapositives · 317 Views · Jan 01, 2020

Explore the 5 generations of programming languages and their trade-offs in terms of productivity, portability, and efficiency. Learn examples from machine language to high-level languages like Java and Prolog. Understand algorithms, their representation, control structures, and flowchart symbols.

Overview of Programming Languages and Algorithms - slide 1
01 / 24Overview of Programming Languages and Algorithms
1 / 17

Télécharger la présentation

Overview of Programming Languages and Algorithms
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. CS 7: Introduction to Computer Programming Algorithms

  2. Review • What are the 5 generation languages (“GL”)? • 1 GL – machine language • 2 GL – assembly language • 3 GL – high level language • 4 GL – “non-procedural, specification language” • 5 GL – “constraint-based, Artificial Intelligence language”

  3. Trade-offs among the 5 G’s • Productivity • Time to write, debug, maintain code • Portability • Ease of taking program written on 1 computer and moving it to another • Efficiency • Time it takes code to run • Amount of space it takes to run • Task Dependent • Is the language developed for a specific task?

  4. 1 GL • Example • 000000 00001 00010 00110 00000 100000 • Add registers 1 and 2, place result in register 6 • Low productivity • Lots of instructions needed for simple tasks • Low portability • Different machine languages for different architectures • High efficiency • can take advantage of architecture dependent features • can write more quick and compact code • Not task dependent • Everything ultimately must be in machine code!

  5. 2 GL - MIPS • Example • add $1, $2, $6 • Add registers 1 and 2, place result in register 6 • Low productivity • Lots of instructions needed for simple tasks • Usually 1-to-1 correspondence with machine language • Easier to read • Low portability • Different machine languages for different architectures • High efficiency • can take advantage of architecture dependent features • can write more quick and compact code • Not task dependent

  6. 3 GL – Java, C++, BASIC, FORTRAN • Example • d = e + f; • Add the values in e and f, place result in d • High productivity • 1 instruction can be 100, 1000 lines of machine code • Much more like human language • Highly portable • Run on any machine with necessary compiler, interpreter • Efficiency • Not as good as machine code • Not task dependent

  7. 4 GL – SQL, Visual Basic’s GUI Creator • Example • FIND ALL RECORDS WHERE NAME IS “HOFFMANN” • High productivity • Easy than 3 GL • Highly portable • Run on any machine with necessary compiler, interpreter • Efficiency • Not as good as machine code or high level language • Task dependent • SQL used for database queries • Visual Basic’s GUI Creator is for designing Graphical User Interfaces (GUIs)

  8. 5 GL – Prolog, Neural Networks • Example • Specify neural network architecture for learning to map written character to ASCII equivalent • High productivity • Highly portable • Efficiency • Not as good as machine code or high level language • Task dependent • Used to solve problems with specific constraints

  9. Some Notes • Syllabus • Typo (5 not 6 projects) • Make sure to read all of the relevant sections of book for the week before the first lecture of that week • Labs start today

  10. Algorithms

  11. Algorithms - Definition • Set of instructions used to complete a task • Can be represented as • Pseudocode – list of steps, is precise but not implemented in programming language • Flowchart – graphical representation

  12. Algorithms - Representation • How do you… • Make a peanut butter sandwich? • Calculative a derivative? • Find a job? • Do the hokey pokey?

  13. Hokey Pokey – List of Steps Representation • Volunteers? • Anything unclear in the steps the song gives?

  14. Flowchart symbols • Action Symbol • Instructions changing a state • Decision Symbol • Instructions testing a state • Flowline • Instructions transferring to next step • Start/End Symbol

  15. Control Structures • Bohm & Jacopini showed all programs could be written in terms of 3 structures: • Sequence – which instruction should be done next? • Selection – select between options • Repetition – repeat an action while a given condition stays true

  16. Sequence • 1) Open the jar • 2) Scoop out the peanut butter • 3) Spread the peanut butter on the bread

  17. Selection • Single Selection (if) • If you’ve won the lottery: raise your hand • Double Selection (if-else) • If you’re happy: smile else: frown True Won lottery? Raise Hand False False True Frown Happy? Smile

  18. Selection (continued) • Multiple Selection (switch) If the light is ... red -> stop green -> go yellow -> slow down True Light Red? Stop False True Light Green? Go False True Light Yellow? Slow Down False

  19. Repetition • While • Do-while while it’s still clumpy Stir the mixture True Mixture Clumpy? Stir False ask parents if must eat vegetables while parents say “Yes” Must I eat Veggies? Parent say “Yes”? True False

  20. Repetition (continued) • For Counter = 1 Teaching a baby to count from 1 to 10: counter = 1 if counter <= 10: increment counter print counter number Add 1 to counter True Counter ≤ 10? Print counter False

  21. Hokey Pokey - Flowchart

  22. Pseudocode • Pseudocode - Algorithm written in way that resembles code: • Example (from BlackJack) method computeScore(cards): for each card in hand: if card is ace: add 1 to score add 1 to numAces else if card is face card: add 10 to score otherwise: add face value to score while numAces > 0 and count < 21: add 10 to counter return counter value

  23. Algorithms - characteristics • What kinds of things are we seeing in these tasks? • They have an input, an output, and do some processing • That processing needs to terminate, be unambiguous, and simple to perform (we want to be able to easily implement it from the algorithm)

  24. References • Deitel, H.M., and Deitel, P.J. Java: How to Program, 3rd edition. Chapter 4,5 • Wikipedia. • http://www.soi.city.ac.uk/~tony/dbms/4ges.html