0% found this document useful (0 votes)
3 views20 pages

Bca

Computer graphics is the field focused on generating and manipulating images using computers, with applications in various industries such as entertainment, education, and medical visualization. It encompasses both raster and vector graphics, and involves the use of specialized software and programming languages to create visual content. The document outlines the core technologies, processes, types, applications, and components of interactive graphics systems, providing a comprehensive overview for those interested in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views20 pages

Bca

Computer graphics is the field focused on generating and manipulating images using computers, with applications in various industries such as entertainment, education, and medical visualization. It encompasses both raster and vector graphics, and involves the use of specialized software and programming languages to create visual content. The document outlines the core technologies, processes, types, applications, and components of interactive graphics systems, providing a comprehensive overview for those interested in the field.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

What is Computer Graphics?

 Definition:
Computer graphics is the field that deals with generating and manipulating images using
computers, encompassing both the technical aspects and the artistic expression.
 Core Technology:
It's a core technology in various industries, including digital photography, film, video
games, digital art, and many specialized applications.
 Process:
Computer graphics involves computations, creation, and manipulation of data to render
images.
Introduction to Computer Graphics
The term ‘Computer Graphics’ was coined by Verne Hudson and William Fetter from Boeing
who were pioneers in the field. Computer graphics is a dynamic and essential field within
computing that involves the creation, manipulation, and rendering of visual content using
computers.
In today’s digital era, computer graphics technologies have revolutionized how we perceive
and interact with visual information, playing a pivotal role in video games, movies,
architectural design, medical imaging, and more. There are several tools used for the
implementation of Computer Graphics. The basic is the graphics.h header file in Turbo-C,
Unity for advanced, and even OpenGL can be used for its Implementation.
This article delves into the fundamental concepts of computer graphics, its diverse
applications, and the underlying technologies that drive innovation in this field.
What is Computer Graphics?
Computer Graphics including digital images, animations, and interactive graphics used in
various sectors such as entertainment, education, scientific visualization, and virtual reality.
Computer Graphics can be used in UI design, rendering, geometric objects, animation, and
many more. In most areas, computer graphics is an abbreviation of CG.
Computer Graphics refers to several things
 The manipulation and the representation of the image or the data in a graphical manner.
 Various technology is required for the creation and manipulation.
 Digital synthesis and its manipulation.
Computer graphics is a wide-ranging topic that covers rendering, modeling, and
visualization techniques. For students preparing for GATE, the GATE CS Self-Paced
Course provides comprehensive lessons on both theoretical and practical aspects of
computer graphics, helping you build a strong foundation.
Types of Computer Graphics
 Raster Graphics: In raster, graphics pixels are used for an image to be drawn. It is also
known as a bitmap image in which a sequence of images is into smaller pixels. Basically,
a bitmap indicates a large number of pixels together.
 Vector Graphics: In vector graphics , mathematical formulae are used to draw different
types of shapes, lines, objects, and so on.
Applications of Computer Graphics
There are many applications of computer graphics discussed below-
 Computer Graphics are used for the aided design of systems engineering and
architectural systems- These are used in electrical automobiles and electro-
mechanical, and electronic devices. For example gears and bolts.
 Computer Art – MS Paint.
 Presentation Graphics – It is used to summarize financial statistical scientific or
economic data. For example- Bar charts systems and line charts.
 Entertainment- It is used in motion pictures, music videos, and television gaming.
 Education and training- It is used to understand the operations of complex systems. It
is also used for specialized systems such as framing for captains, pilots, and so on.
 Visualization- To study trends and patterns. For example- Analyzing satellite photos of
earth.
Why are Computer Graphics used?
Imagine a car manufacturing company that wants to showcase its vehicle sales over the
past decade. Storing and presenting this huge amount of data can be both time-consuming
and memory-intensive. Furthermore, it can be difficult for the average person to understand.
In such cases, by using graphics can be a more effective solution. By using charts and
graphs to visually signify the data, it becomes much easier to understand and analyse the
data.
Interactive computer graphics utilize a two-way communication concept between users and
computers. The computer receives input signals from the user, and the picture is modified
accordingly. When a command is applied, the picture updates promptly.
How To Get Started in Computer Graphics
Step by step process to getting started with computer graphics-
Step-1: Understaind the basics
Learn the fundamental and basics of computer graphics such as rendering, shading,
animation, and modeling. Learn basic concepts of mathematics like linear
algebra, geometry, and calculus as well as basic principles of physics that support computer
graphics.
Step-2: Choose Your Area of Interest
Choose your area of interest like 2D-Graphics, 3D-Graphics, Animation, and special
effect (VFX).
Step-3: Learn Programming
Learn programming language that is used in graphics, such as Python, C++,
and JavaScript. Learn about Graphics Libraries and APIs like OpenGL, Vulkan, DirectX, and
frameworks like WebGL that is used in web based graphics.
Step-4: Use Graphics Software
Learn about modeling and animation tools such as Blender, Autodesk Maya, or 3ds
Max for 3D modeling and animation. Learn about 2D-Graphics software like Adobe
Photoshop, Illustrator, and GIMP.
Step-5: Study and Practice
Take online courses and tutorials, many institution offer Computer Graphics course like
Coursera, Udemy, and Khan Academy. And read textbooks like “Computer Graphics:
Principles and Practice” by John F. Hughes. Now, Starts with simple projects, such as
creating basic shapes and gradually move on to more complex scenes and animations.
Step-6: Create a portfolio of your work
create your own projects and build an online portfolio to display your work, which is helpful
for job application.
Step-7: Apply for jobs in computer graphics
If you aim to build a career in computer graphics and grow in this field, gaining experience is
important. Search for entry-level positions, freelance, contract work, and internships. When
searching for jobs, read the descriptions carefully to understand the responsibilities, required
qualifications, and company details. This will help you find roles that align with your career
goals and skill set.

Applications of Computer Graphics


Computer graphics is the part of computer science that studies methods for manipulating
visual content although computer graphics deals with 3D graphics, 2D graphics, and image
processing. It also deals with the creation, manipulation, and storage of different types of
images and objects. There are some of the applications of computer graphics are described
below.:
 Computer Art: Using computer graphics we can create fine and commercial art which
includes animation packages, and paint packages. These packages provide facilities for
designing object shapes and specifying object motion. Cartoon drawings, paintings, and
logo designs can also be done.
 Computer-Aidedautomobiles Drawing: Designing buildings, automobiles, and aircraft is
done with the help of computer-aided drawing, this helps in providing minute details to
the drawing and producing more accurate and sharp drawings with better specifications.
 Presentation Graphics: For the preparation of reports or summarising the financial,
statistical, mathematical, scientific, and economic data for research reports, and
managerial reports, moreover creation of bar graphs, pie charts, and time charts, can be
done using the tools present in computer graphics.
 Entertainment: Computer graphics find a major part of its utility in the movie industry
and game industry. Used for creating motion pictures, music videos, television shows,
and cartoon animation films. In the game industry where focus and interactivity are the
key players, computer graphics help in efficiently providing such features.
 Education: Computer-generated models are extremely useful for teaching huge number
of concepts and fundamentals in an easy-to-understand and learn manner. Using
computer graphics many educational models can be created through which more interest
can be generated among the students regarding the subject.
 Training: Specialised systems for training like simulators can be used for training the
candidates in a way that can be grasped in a short span of time with better
understanding. The creation of training modules using computer graphics is simple and
very useful.
 Visualization: Today the need of visualize things have increased drastically, the need of
visualization can be seen in many advanced technologies, data visualization helps in
finding insights into the data, to check and study the behavior of processes around us we
need appropriate visualization which can be achieved through proper usage of computer
graphics.
 Image Processing: Various kinds of photographs or images require editing in order to
be used in different places. Processing of existing images into refined ones for better
interpretation is one of the many applications of computer graphics.
 Machine Drawing: Computer graphics are very frequently used for designing,
modifying, and creating various parts of a machine and the whole machine itself, the
main reason behind using computer graphics for this purpose is the precision and clarity
we get from such drawing is ultimate and extremely desired for the safe manufacturing of
machine using these drawings.
 Graphical User Interface: The use of pictures, images, icons, pop-up menus, and
graphical objects helps in creating a user-friendly environment where working is easy
and pleasant, using computer graphics we can create such an atmosphere where
everything can be automated and anyone can get the desired action performed in an
easy fashion.
These are some of the applications of computer graphics due to which it’s popularity has
increased to a huge extend and will keep on increasing with the progress in technology.
Applications of Computer Graphics
 Entertainment and Media:
This includes film, television, video games, and animation.
 Virtual Reality (VR) and Augmented Reality (AR):
Computer graphics are essential for creating immersive and interactive experiences in VR
and AR.
 Medical Visualization:
Computer graphics helps doctors visualize complex medical data, such as 3D models of
organs or tissues.
 Architectural Visualization:
Architects use computer graphics to create realistic renderings of buildings and designs.
 Education and Training:
Computer graphics can be used to create interactive simulations and educational
materials.
 Scientific Visualization:
Scientists use computer graphics to visualize complex data and models, such as weather
patterns or molecular structures.
 Industrial Design and Manufacturing:
Computer graphics are used for product design, prototyping, and manufacturing
processes.
 Advertising and Marketing:
Computer graphics are used to create visually appealing advertisements and marketing
materials.
 User Interface Design:
Computer graphics play a crucial role in designing user-friendly interfaces for software and
applications.

Example of Computer Graphics Packages:


 LOGO
 COREL DRAW
 AUTO CAD
 3D STUDIO
 CORE
 GKS (Graphics Kernel System)
 PHIGS
 CAM (Computer Graphics Metafile)
 CGI (Computer Graphics Interface)
Components of Interactive Graphics Systems

Interactive graphics systems are designed to allow users to manipulate graphical images
and objects in real-time, providing an engaging experience for applications such as video
games, simulations, educational tools, and virtual reality environments. These systems
comprise several key components that work together to create interactive and dynamic
visual representations. Below are the primary components of interactive graphics systems:

1. Input Devices
 Mouse: Used for precise pointer control, click actions, and dragging objects on the screen.
 Keyboard: Allows users to input commands or interact with the system through shortcuts or
keys.
 Touch Screens: Enable direct interaction with graphical elements using fingers or styluses.
 Game Controllers: Provide specialized input methods for gaming environments, facilitating
intuitive control over game characters and actions.
 Motion Sensors: Used in immersive systems (like virtual reality) to detect body movements
and gestures.
2. Graphics Processing Unit (GPU)
 A dedicated processor designed to accelerate graphics rendering. GPUs are essential for
real-time rendering of complex graphics, enabling smooth interactions and high frame rates.
3. Rendering Engine
 This component processes graphics data and transforms it into visual images on the screen.
It handles tasks such as:
o Rasterization: Converting 3D models into 2D images.
o Shading: Applying colors, textures, and effects to objects.
o Lighting Models: Simulating natural and artificial lighting interactions with objects.
4. Graphics API
 Application Programming Interfaces (APIs) like OpenGL, DirectX, and Vulkan provide a set
of functions and protocols for developers to create graphics applications. They enable
communication between the application and the hardware (GPU) to perform rendering
tasks.
5. Scene Graph
 A data structure that organizes the logical representation of a graphical scene, maintaining a
hierarchical relationship between elements (nodes, objects). The scene graph simplifies
rendering and state management by allowing efficient traversal and transformation of
objects.
6. Animation System
 Manages the timing and movement of objects within the graphical environment. This
component ensures smooth transitions, frame rates, and realistic motions, often employing
techniques such as keyframing, skeletal animation, and physics-based simulation.
7. User Interface (UI) Components
 Elements such as buttons, sliders, menus, and dialog boxes that facilitate user interaction
with the system. UI components must be visually appealing and functional, providing
feedback and clear pathways for interaction.
8. Event Handling System
 This component detects and manages user inputs and interactions, such as mouse
movements, clicks, keyboard presses, and gestures. It connects these events to relevant
actions within the application.
9. Audio System
 While primarily concerned with graphics, many interactive systems incorporate audio
components to enhance the experience. This includes sound effects, background music,
and spatial audio, creating a more immersive environment.
10. Networking Components
 In multi-user or online interactive graphics environments (e.g., multiplayer games),
networking components handle communication between clients and servers, synchronizing
user actions and data exchange.
11. Storage Management
 Responsible for managing data related to graphics assets (textures, models, audio files) and
user data (preferences, settings). Efficient storage management ensures rapid access to
required resources.
Conclusion
Interactive graphics systems rely on a combination of hardware (input devices and GPUs)
and software (rendering engines, APIs, event handling) to create responsive and dynamic
visual experiences. By integrating these components effectively, developers can create
applications that engage users and respond fluidly to their inputs, enhancing immersion and
interactivity. As technology evolves, so do the possibilities for interactive graphics, paving
the way for more innovative and sophisticated applications.
Real-life Applications of Data Structures and Algorithms (DSA)
You may have heard that DSA is primarily used in the field of computer
science. Although DSA is most commonly used in the computing field,
its application is not restricted to it. The concept of DSA can also be
found in everyday life. Here we’ll address the common concept of DSA
that we use in our day-to-day lives.
Application of Data Structure:
A data structure is a particular way of organizing data in a computer so
that it can be used effectively. The real-life applications of all the data
structures are discussed below.
Application of Arrays:
Arrays are the simplest data structures that store items of the same
data type. A basic application of Arrays can be storing data in tabular
format. For example, if we wish to store the contacts on our phone,
then the software will simply place all our contacts in an array.
Some other applications of the arrays are:
 Arrangement of the leader board of a game can be done simply
through arrays to store the score and arrange them in descending
order to clearly make out the rank of each player in the game.
 A simple question Paper is an array of numbered questions with each
of them assigned some marks.
 2D arrays, commonly known as, matrices, are used in image
processing.
 It is also used in speech processing, in which each speech signal is
an array.
 Your viewing screen is also a multidimensional array of pixels.
 Book titles in a Library Management Systems.
 Online ticket booking.
 Contacts on a cell phone.
 For CPU scheduling in computer.
 To store the possible moves of chess on a chessboard.
 To store images of a specific size on an android or laptop.

Application of Strings:
 Spam email detection.
 Plagiarism detection.
 Search engine.
 Digital forensic and information retrieval system
 Spell checkers.
 In the database to check valid information of the user

Application of Matrix:
Matrix is an ordered collection of columns and rows of elements. It is
necessary to enclose the elements of a matrix within the brackets.
Some applications of a matrix are:
 In geology, matrices are used for making seismic surveys.
 Used for plotting graphs, and statistics and also to do scientific
studies and research in almost different fields.
 Matrices are also used in representing real-world data like the
population of people, infant mortality rate, etc.
 They are the best representation methods for plotting surveys.
 For refraction and reflection in science optics.
 Electronic circuit and quantum physics.
 Media player.
 Mailing list.
 Symbol table creation.

Application of Linked Lists:


A linked list is a sequence data structure, which connects elements,
called nodes, through links.
Some other applications of the linked list are:
 Images are linked with each other. So, an image viewer software
uses a linked list to view the previous and the next images using the
previous and next buttons.
 Web pages can be accessed using the previous and the next URL
links which are linked using a linked list.
 The music players also use the same technique to switch between
music.
 To keep the track of turns in a multi-player game, a circular linked
list is used.
 MS-Paint drawings and shapes are connected via a linked list on
canvas.
 Social media content “feeds”.
 Used for symbol table management in a designing compiler
 Used in switching between applications and programs (Alt + Tab) in
the Operating system (implemented using Circular Linked List)
 Train coaches are connected to one another in a doubly-linked list
fashion.
 It can be used to implement Stacks, Queues, Graphs, and Trees.
 To perform undo operation.
 Back button.[LIFO]
 Syntax in the coding editor.
 History of visited pages.
Application of Stack:
A stack is a data structure that uses LIFO order.
Some Applications of a stack are:
 Converting infix to postfix expressions.
 Undo/Redo button/operation in word processors.
 Syntaxes in languages are parsed using stacks.
 It is used in many virtual machines like JVM.
 Forward-backward surfing in the browser.
 History of visited websites.
 Message logs and all messages you get are arranged in a stack.
 Call logs, E-mails, Google photos’ any gallery, YouTube downloads,
Notifications ( latest appears first ).
 Scratch card’s earned after Google pay transaction.
 Wearing/Removing Bangles, Pile of Dinner Plates, Stacked chairs.
 Changing wear ables on a cold evening, first in, comes out at last.
 Last Hired, First Fired - which is typically utilized when a company
reduces its workforce in an economic recession.
 Loading bullets into the magazine of a gun. The last one to go in is
fired first. Bam!
 Java Virtual Machine.
 Recursion.
 Used in IDEs to check for proper parentheses matching
 Media playlist. T o play previous and next song
Application of Queue:
A queue is a data structure that uses FIFO order.
Some applications of a queue are:
 Operating System uses queues for job scheduling.
 To handle congestion in the networking queue can be used.
 Data packets in communication are arranged in queue format.
 Sending an e-mail, it will be queued.
 Server while responding to request
 Uploading and downloading photos, first kept for
uploading/downloading will be completed first (Not if there is
threading)
 Most internet requests and processes use queue.
 While switching multiple applications, windows use circular queue.
 In Escalators, Printer spooler, Car washes queue.
 A circular queue is used to maintain the playing sequence of multiple
players in a game.
 A queue can be implemented in - Linked List-based Queue, Array-
based Queue, Stack-based Queue.
 Uploading and downloading photos, first kept for
uploading/downloading will be completed first (Not if there is
threading).
 Handle website traffic
 CPU scheduling
Application of Priority Queue:
 Process scheduling in the kernel.
 Priority queues are used in file-downloading operations in a browser
 Vehicle at the toll center.
Application of Graph:
Graph is a data structure where data is stored in a collection of
interconnected vertices (nodes) and edges (paths).
Some applications of a graph are:
 Facebook’s Graph API uses the structure of Graphs.
 Google’s Knowledge Graph also has to do something with Graph.
 Dijkstra algorithm or the shortest path first algorithm also uses graph
structure to find the smallest path between the nodes of the graph.
 The GPS navigation system also uses shortest path APIs.
 Networking components have a huge application for graph
 Facebook, Instagram, and all social media networking sites every
user is Node
 Data organization
 React’s virtual DOM uses graph data structures.
 MS Excel uses DAG (Directed Acyclic Graphs).
 Path Optimization Algorithms, BFS, DFS.
 Recommendation Engines.
 Scientific Computations, Flight Networks, Page ranking.
 Google map to find nearest location.
 Facebook to suggest mutual friends
Application of Tree:
Trees are hierarchical structures having a single root node.
Some applications of the trees are:
 XML Parser uses tree algorithms.
 The decision-based algorithm is used in machine learning which
works upon the algorithm of the tree.
 Databases also use tree data structures for indexing.
 Domain Name Server(DNS) also uses tree structures.
 File explorer/my computer of mobile/any computer
 BST used in computer Graphics
 Posting questions on websites like Quora, the comments are a child
of questions.
 Parsers(XML parser).
 Code Compression(zip).
 DOM in Html.
 Evaluate an expression (i.e., parse).
 Integral to compilers/automata theory.
 To store the possible moves in a chess game.
 To store the genealogy information of biological species.
 Used by JVM (Java Virtual Machine) to store Java objects.
Application of Binary Search Tree:
 D Game Engine.
 Computer Graphics Rendering.
 Routing table.
Application of RED-BLACK Tree
 Used when there is frequent Insertion/Deletion and few searches.
 K -mean Clustering using a red-black tree, Databases, Simple-minded
database, searching words inside dictionaries, searching on the web.
 Process Scheduling in Linux.
Application of AVL Tree
 More Search and less Insertion/Deletion.
 Data Analysis and Data Mining and the applications which involve
more searches.
Application of SUFFIX Tree
 Fast full-text search, used in most word processors.
Application of TRIE
 Dictionary application.
 Autocomplete feature in searching.
 Auto-completing the text and spells checking.
Application of Hash Tables:
Hash Tables are store data in key-value pairs. It only stores data that
has a key associated with it. Inserting and Searching operations are
easily manageable while using Hash Tables.
Some applications of a hashtable are:
 Data stored in databases is generally of the key-value format which
is done through hash tables.
 Every time we type something to be searched in google chrome or
other browsers, it generates the desired output based on the
principle of hashing.
 Message Digest, a function of cryptography also uses hashing for
creating output in such a manner that reaching the original input
from that generated output is almost next to impossible.
 In our computers we have various files stored in it, each file has two
very crucial pieces of information that is, the filename and file path,
in order to make a connection between the filename to its
corresponding file path hash tables are used.
 Social network “feeds”.
 Password hashing.
 Used for fast data lookup - symbol table for compilers, database
indexing, caches, Unique data representation.
 To store a set of fixed keywords that are referenced very frequently.
Application of Heap:
A Heap is a special case of a binary tree where the parent nodes are
compared to their children with their values and are arranged
accordingly.
Some applications of heaps are:
 In heapsort Algorithm, is an algorithm for sorting elements in
either min heap(the key of the parent is less than or equal to those
of its children) or max heap(the key of the parent is greater than or
equal to those of its children), sorting is done with the creation of
heaps.
 Heaps are used to implementing a priority queue where priority is
based on the order of heap created.
 Systems concerned with security and embedded system such as
Linux Kernel uses Heap Sort because of the O( n log(n) ).
 If we are stuck in finding the Kthsmallest (or largest) value of a
number then heaps can solve the problem in an easy and fast
manner.
 Used by JVM (Java Virtual Machine) to store Java objects.
Application of Algorithms:
Algorithms are well-defined sets of instructions designed that are used
to solve problems or perform a task. To explain in simpler terms, it is a
set of operations performed in a step-by-step manner to execute a task.
The real-life applications of algorithms are discussed below.
Application of Sorting Algorithms
 Order things by their value.
 Backend Databases (Merge Sort).
 Playing Cards with your friends (Insertion Sort).
 sort() - uses IntroSort (a hybrid of Quicksort, Heapsort, and Insertion
Sort), Faster than qsort()
 The contact list on the phone

 Online shopping. To sort prize in different range . example : flipkart


and amazon.
Application of Greedy Algorithms:
 Dijkstra algorithm.
 Shopping on a tight budget but want to buy gifts for all family
members.
 Prim’s and Kruskal’s algorithms are used for finding the minimum
spanning trees.
Application of Dijkstra Algorithm
 Used in applications like Google Maps to find the shortest path in a
graph.
Application of PRIM’S and
KRUSKAL’S Algorithm
 Used for finding the minimum spanning trees.
Application of Dynamic Programming
Algorithms:
 In Google Maps to find the shortest path between the source and the
series of destinations (one by one) out of the various available paths.
 In networking to transfer data from a sender to various receivers in a
sequential manner.
Application of Backtracking Algorithms:
 Suppose we are coding a chess-playing algorithm and at a certain
point, the algorithm finds that a set of steps fails to win. In this
situation, the algorithm will reverse back to the safe state and try
another possible set of steps.
 Sudoku solver
 2048 game
 Computer networking.
 To solve problem of the N Queen.
 To solve the problem of the Maze.
 To find the Hamiltonian Path present in a graph.
 To the love problem of Knight’s Tour Problem.

Arrays Data Structure


An array is a linear data structure and it is a collection of element of same data
type stored at contiguous memory locations.
It offers mainly the following advantages.
 Random Access: i-th elements can be accessed in O(1) Time as we have
the base address and every element is of same size.
 Cache Friendliness: Since elements are stored at contiguous locations, we
get the advantage of locality of reference.

Different applications of an array are as follows:


Arrays efficiently manage and store database records.
 It helps in implementing sorting algorithm.
 It is also used to implement other data structures like Stacks, Queues, Heaps,
Hash tables, etc.
 An array can be used for CPU scheduling.
Want to get started with arrays? You can try out our curated articles and
lists for the best practice:
 Top 50 Array Coding Problems for Interviews
 Practice Array Problems
 Search, Insert, and Delete in an Array
Linked list Data Structure
A linked list is a linear data structure in which elements are not stored at
contiguous memory locations. The elements in a linked list are linked using
pointers as shown in the below image.

Applications of the Linked list


 Linked lists are used to implement other data structures like stacks, queues,
etc.
 It is used for the representation of sparse matrices.
 It is used in the linked allocation of files.
 Linked lists are used to display image containers. Users can visit past,
current, and next images.
 They are used to perform undo operations.
Want to get started with a linked list? You can try out our curated articles
and lists for the best practice:
 Introduction to Linked list Data Structure
 Top 20 Linked list Interview Questions
 Practice Linked List Problems
Stack Data Structure
Stack is a linear data structure that follows LIFO(Last in first out) principle i.e.,
entering and retrieving data is possible from only one end. The entering and
retrieving of data is also called push and pop operation in a stack.

Applications of Stack
Different applications of Stack are as follows:
 The stack data structure is used in the evaluation and conversion of
arithmetic expressions.
 It is used for parenthesis checking and string reversal.
 A memory stack is also used for processing function calls.
 The stack is used in virtual machines like JVM.
Want to get started with Stack? You can try out our curated articles and lists for
the best practice:
 Introduction to Stack Data Structure
 Practice Stack Problems
Queue Data Structure
Queue is a linear data structure that follows First In First Out(FIFO) principle
i.e. the data item stored first will be accessed first. In this, entering is done from
one end and retrieving data is done from other end. An example of a queue is
any queue of consumers for a resource where the consumer that came first is
served first.

Applications of Queue:
Different applications of Queue are as follows:
 Queue is used for handling website traffic.
 It helps to maintain the playlist in media players.
 It helps in serving requests on a single shared resource, like a printer, CPU
task scheduling, etc.
 Queues are used for job scheduling in the operating system.
Want to get started with Queue? You can try out our curated articles and lists for
the best practice:
 Introduction to Queue Data Structure
 Practice Queue Problems
Tree Data Structure
A tree is a non-linear and hierarchical data structure where the elements are
arranged in a tree-like structure. In a tree, the topmost node is called the root
node. Each node contains some data, and data can be of any type. It consists of
a central node, structural nodes, and sub-nodes which are connected via edges.
Different tree data structures allow quicker and easier access to the data as it is
a non-linear data structure.
Tree

Applications of Tree:
 Heap is a tree data structure that is implemented using arrays and used to
implement priority queues.
 B-Tree and B+ Tree are used to implement indexing in databases.
 Syntax Tree helps in scanning, parsing, generation of code, and evaluation of
arithmetic expressions in Compiler design.
 Spanning trees are used in routers in computer networks.
 Domain Name Server also uses a tree data structure.
Want to get started with Tree? You can try out our curated articles and
lists for the best practice:
 Introduction to Tree Data Structure
 Top 50 Tree Interview Questions
 Practice Tree Problems
Binary Search Tree Data Structure
A Binary Search Tree (or BST) is a data structure used for organizing and
storing data in a sorted manner. Each node in a Binary Search Tree has at
most two children, a left child and a right child, with the left child containing
values less than the parent node and the right child containing values greater
than the parent node. This hierarchical structure allows for
efficient searching, insertion, and deletion operations on the data stored in the
tree.
Applications of Binary Search Tree:
 A Self-Balancing BST maintains a sorted stream of data in RAM, useful for
tracking online orders by price and querying item counts above or below a
given cost.
 It enables a doubly-ended priority queue, supporting
both extractMin() and extractMax() in O(log n) time, unlike a Binary Heap.
 Many algorithmic problems, like counting smaller elements on the right or
finding the smallest greater element, benefit from a Self-Balancing BST.
 TreeMap and TreeSet in Java, and set and map in C++, are implemented
using Red-Black Trees, a type of Self-Balancing BST.
Want to get started with BST? You can try out our curated articles and lists
for the best practice:
 Introduction to Binary Search Tree
 Top 50 Binary Search Tree Coding Problems for Interviews
Graph Data Structure
A graph is a non-linear data structure that consists of vertices (or nodes) and
edges. It consists of a finite set of vertices and set of edges that connect a pair
of nodes. The graph is used to solve the most challenging and complex
programming problems. It has different terminologies which are Path, Degree,
Adjacent vertices, Connected components, etc.

Graph

Applications of Graph:
 The operating system uses Resource Allocation Graph.
 Also used in the World Wide Web where the web pages represent the nodes.
 One of the most common real-world examples of a graph is Google Maps
where cities are located as vertices and paths connecting those vertices are
located as edges of the graph.
 A social network is also one real-world example of a graph where every
person on the network is a node, and all of their friendships on the network
are the edges of the graph.
In data structures, an array is a fundamental, linear data structure that stores a collection of
elements of the same data type in contiguous memory locations, allowing for efficient access to
each element using an index. They exist in both single dimension and multiple dimensions.
These data structures come into picture when there is a necessity to store multiple
elements of similar nature together at one place. An array is a data structure that organizes a
fixed-size collection of elements of the same type, stored contiguously in memory.

Applications:
Arrays are used to store and manipulate data in various applications, including:
 Storing lists of items (e.g., a shopping list, a list of student names).
 Implementing other data structures like stacks, queues, and linked lists.
 Representing matrices in numerical computations.
 Sorting and searching data.

Advantages:
 Fast Access: Accessing an element by its index is a very fast operation (constant time, O(1)).
 Simple Implementation: Arrays are relatively easy to implement and understand.
Disadvantages
 Fixed Size: As mentioned, the size of an array is typically fixed, which can be a limitation if
you need to store a variable number of elements.
 Insertion and Deletion: Inserting or deleting elements in the middle of an array can be
inefficient, as it may require shifting other elements in memory.

The difference between an array index and a memory address is that the array
index acts like a key value to label the elements in the array. However, a memory
address is the starting address of free memory available.
Element − Each item stored in an array is called an element.
Index − Each location of an element in an array has a numerical index, which is
used to identify the element.

Syntax: Creating an array in C and C++ programming languages −


data_type array_name[array_size]={elements separated by commas}
or,
data_type array_name[array_size];
data_type[] array_name = {elements separated by commas}
Need for Arrays
Arrays are used as solutions to many problems from the small sorting problems to
more complex problems like travelling salesperson problem. There are many data
structures other than arrays that provide efficient time and space complexity for
these problems, so what makes using arrays better? The answer lies in the random
access lookup time. Arrays provide O(1) random access lookup time. That means,
accessing the 1 st index of the array and the 1000 th index of the array will both take
the same time. This is due to the fact that array comes with a pointer and an offset
value. The pointer points to the right location of the memory and the offset value
shows how far to look in the said memory.
array_name[index]
| |
Pointer Offset
Therefore, in an array with 6 elements, to access the 1st element, array is pointed
towards the 0th index. Similarly, to access the 6 th element, array is pointed towards
the 5th index.

Array Representation
Arrays are represented as a collection of buckets where each bucket stores one
element. These buckets are indexed from '0' to 'n-1', where n is the size of that
particular array. For example, an array with size 10 will have buckets indexed from
0 to 9.

This indexing will be similar for the multidimensional arrays as well. If it is a 2-


dimensional array, it will have sub-buckets in each bucket. Then it will be indexed as
array_name[m][n], where m and n are the sizes of each level in the array.

 Index starts with 0.


 Array length is 9 which means it can store 9 elements.
 Each element can be accessed via its index. For example, we can fetch an element
at index 6 as 23.

Basic Operations in Arrays


 The basic operations in the Arrays are insertion, deletion, searching, display, traverse,
and update. These operations are usually performed to either modify the data in the
array or to report the status of the array. basic operations
 Traverse − print all the array elements one by one.
 Insertion − Adds an element at the given index.
 Deletion − Deletes an element at the given index.
 Search − Searches an element using the given index or by the value.
 Update − Updates an element at the given index.Display − Displays the contents
of
 the array.
1. Contiguous Memory Allocation:
o A linear array is stored in contiguous memory locations. This means that if an array has n elements, the
memory allocated will consist of n consecutive slots.
o For example, if an integer array of size 5 is declared, say int arr[5];, and the first element is stored at
memory address base_address, then the subsequent elements will be stored at:
 arr[0] -> base_address
 arr[1] -> base_address + sizeof(data_type)
 arr[2] -> base_address + 2 * sizeof(data_type)
 arr[3] -> base_address + 3 * sizeof(data_type)
 arr[4] -> base_address + 4 * sizeof(data_type)

Here, `sizeof(data_type)` is the memory size (in bytes) of each element in the array, which depends on the
data type used (e.g., `int`, `float`, `char`, etc.).

2. Base Address:
o The first element of the array is often referred to as the base address. The base address holds the location of
the first element, and all other elements are accessed using index offsets calculated from this base address.
3. Example: Suppose you have an integer array with these values:

int arr[5] = {10, 20, 30, 40, 50}; Assuming sizeof(int) is 4 bytes and the starting
base_address is 1000, the memory representation would look like this:
Memory Address | Value
------------------|---------
1000 | 10
1004 | 20
1008 | 30
1012 | 40
1016 | 50
Conclusion
Linear arrays have a straightforward representation in memory, relying on contiguous blocks to store elements
efficiently. Understanding this representation is essential in various algorithms and data manipulation tasks
where direct index access is required. This direct mapping allows for efficient read and write operations, which
is one of the reasons arrays are widely used in programming.

You might also like