data structures

16
WEEK # 1 WEEK # 1 LECTURE 1

Upload: ameer-ali

Post on 27-Jan-2016

218 views

Category:

Documents


0 download

DESCRIPTION

Data Structures

TRANSCRIPT

WEEK # 1WEEK # 1

LECTURE 1

What is a Language??

A language is basically a phenomenon which provides a way to express concepts.

Therefore, language should have all the attributes through which a human can

express easily his/her thoughts, feelings, concepts etc. Consider an English Language through which one can easily express his

concepts and feeling.

English Language is basically a Human Language.

Why Human Language?? Because all the processing of the Language is occurred in the Human Brain.

Similarly,Computer Language?? All the processing of the language is occurred in the brain (CPU) of the

computer.

Computer

A computer is a device capable of performing all kind of tasks and makes logical decisions.

A computer can do almost all the things that humans can do. Then why we need computers ??

One of the major reason behind that is it will make all the tasks at speeds millions (even billions) of times faster than human beings can.

For example, A person operating desk calculators could spent many years of his life calculating and still not complete as many calculations as a powerful personal computer can perform in one second.

In order to perform simplest job (may be addition of two numbers) computers need instructions from the user. Now, how can we give these

Programming is the way of giving instructions to the computers so that machine will execute the desired task.

As a set of instructions (or commands) is known as a programme.

• Just like human language is a way of communication between human and human,• similarly, computer language is a way of communication between human and computer.

Computer Language: The computer language we used in this course is C++.Other Computer Languages: 1. C 2. Java 3. Visual Basic 4. Assembly Language

Now, we cannot understand each and every language. This is just like an example there are many human languages like English, Arabic, German, French etc. But as we only try to learn the English Language because it is mostly used in the World, similarly, we will understand the C++ language because it is most widely used and normally worked in most conditions.

Tools (Software or Complier) for C++ Language

There are number of tools i.e. software or compiler in which we can write our programs in C++ like

1. Turbo C (C++) 2. Borland C (C++) 3. Microsoft Visual C++

But we will use the software Microsoft Visual C++ because it has the environment just like MS Word, so it is more user friendly environment.

Computer Organization

• The are mainly five unit in computer organization.– Input Unit– Memory Unit– Output Unit– Arithmetic Logic Unit (ALU)– Central Processing Unit (CPU)

Input Unit Computer obtained information from input devices attached to it like

keyboard, mouse etc.

Memory Unit The input information is stored in the memory unit that has been entered

through input unit so that it will be immediately available for processing when needed.

The memory unit also retains processed information until it can be placed

on output devices by the output unit.

Information in the memory unit is typically lost when the computers power is turned off. Memory units in computers are also known as RAM (Read/Write Memory or Random Access Memory).

• Output Unit– Computer takes information from the memory that has been processed and

places on the output devices to make the information available for use outside the computers. Like Printers, Monitors.

• Arithmetic Logic Unit (ALU) – This unit is responsible for performing calculations such as additions,

subtractions, multiplications and divisions etc. It is also responsible for logic issues like OR, AND, XOR, Compare operations.

• Central Processing Unit (CPU) – The CPU tells the input unit when information should be read and put it on the

memory location for processing. It also tells the ALU when information from the memory unit should be used in calculations and also tells the output unit when to send information from the memory unit to certain output devices.

Introduction to Computer Languages

• There are three types of programming languages.1. Machine Language2. Assembly Language3. High-Level Language

Machine Language

Early when computer was first invented, there programs are prepared in machine language using a code based on the binary number system (0`s & 1`s).

Note: Computers are Digital Systems i.e. All of their working occurs in the forms of 0`s and 1`s.

This method of giving instructions soon limited the complexity of the problems because even the simplest program consists of thousands of 0`s and 1`s. So, Assembly Language is introduced.

Assembly Language (Low-Level Language)

• They are considered the second generation of programming languages. Assembly Language allows a programmer to design a program and translate it into machine language using a piece of software called an assembler.

• “In other words, you can design your program using English language words i.e. abbreviations”.

• However, the biggest disadvantage of assembly language is that they are processor specific. This means that programs written in assembly language will only work on processor similar one of the machine that they are written to. Like, Assembly code written for Intel Processor based machine cannot run on IBM Processor based machine.

High-Level Language

• They are considered as the Third generation language. They are similar to Assembly Language but they are not processor specific.

• A program written in this language will be able to run on any machine.

• Third generation languages are much more abstract than assembly language i.e. it is closer to English Language and more user friendly.

• Programs written in High-Level Language are translated into assembly language by a software called compiler.

C Language which permits very efficient code but less user friendly.

C++ Superset of C "Spruces up" C, and provides object-oriented capabilities Object-oriented design very powerful

Support of different date type and their reuse Important language in industry

JAVA vs C++ Java create cross-platform programs and C++ can’t because of the type of code

produced by the compiler.

In the case of C++, the output from the compiler is machine code.

Java compile a program into a intermediate language. This intermediate language is called bytecode/ pseudocode. This pseudocode is executed further by another software named runtime software. A Java program can run in any environment.

Since the Java runtime software stand between a program and the CPU, Java programs face slow processing speed that is not present in the execution of a C++ program. This is why C++ programs usually run faster than the equivalent programs written in Java .

Java was developed in response for the online environment of the Internet. The Internet is connected to many different types of CPUs and operating systems. Thus, the ability to produce cross-platform programs became an overriding concern.

Using Java, it is possible to write a program that runs in a wide variety of environments. Thus, a Java program can move about freely on the Internet. However, the price you pay for portability is efficiency, and Java programs execute more slowly than do C++ programs.

In the final analysis, if you want to create high-performance software, use C++. If you need to create highly portable software, use Java .

One final point: Remember that C++ and Java, are designed to solve different sets of problems. It is not an issue of which language is best in and of itself. Rather, it is a question of which language is right for the job at hand.