Assignment 3
Assignment 3
Assignment 3
Assignment 3
What is C++?
11. C++ is an object oriented programming (OOP) language. OOP means that
programming is done through objects. These objects encapsulate data and
functions that operate on the data or other functions.
12. C++ programs must be compiled before being executed.
C++ Structures and Constructs
• C++ also has structures and constructs. These control the language. These
include simple structures such as sequential structures, repetition structures and
selection structures.
C++ Structures and Constructs
• Sequential structures allow the program to flow in the order instructions are
placed. This is the default for C++.
• Repetition structures include for, do…while and while loops which repeat a
part of the program.
• Selection structures include if…then, if…then…else, if…then…elseif and
switch which allows the program to execute a different part of the program
depending on a condition.
Functions
• Data Structures are the way data is stored such that the data can be operated on
smoothly.
• Data structures include arrays, linked lists, stacks, queues, hash tables, trees,
heaps and graphs.
Data Types and Structures
• Arrays store data of the same type in locations next to each other. They are of a
set size and the locations are numbered starting from 0. Data is accessed by
going to the number (index) that contains the necessary data.
• Linked lists store data in nodes, which are sorted linearly. Each node is linked
to the next by a pointer. Data accessed by going from the head (pointer to the
first data storage location) to the node that contains the necessary data. Each
node is only connected to one other node.
Data Types and Structures
• Stack store data in a last in first out manner meaning that the first piece of data
that can be accessed first is the last piece of data stored.
• Queues store in a first in first out manner meaning that the first piece of data
that can be accessed first is the first piece of data stored.
Data Types and Structures
• Hash tables store data and associate each piece with a key. Data is accessed by
looking for and accessing the key of that data.
• Trees store data in a linked hierarchy. This means that there are levels on which
data is stored and they can be accessed by going from one piece of data to the
next due to being linked. Like linked lists, data is stored in nodes but a node on
a higher level can be connected to multiple lower level nodes.
Data Types and Structures
• Heaps are a specific type of tree where the data in each level of the hierarchy is
determined by comparing the data in each level and arranging them in a
specific order based of that comparison.
• Graphs store data in nodes or vertices. These vertices can be connected to each
other by edges. Unlike trees and linked list, not all nodes have to be connected,
nodes do not have to be sorted or be in a specific order like a hierarchy or on a
line.
References