Practical Data Structures
Practical Data Structures
net/publication/342765636
CITATIONS READS
2 2,772
1 author:
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Mohammad Ali H. Eljinini on 08 July 2020.
2019
Practical
Data Structures
C++, C#, and Java
M.A. Eljinini
English
ISBN: 978-9957-67-401-4
Arabic
i
Practical Data Structures with C++, C#, and Java
First Edition
987654321
ISBN: 978-9957-67-401-4
ii
M.A. Eljinini
Content
iii
Practical Data Structures with C++, C#, and Java
iv
M.A. Eljinini
v
Practical Data Structures with C++, C#, and Java
vi
M.A. Eljinini
Preface
Computer Scientists have developed many programming languages, from assembly language in
the 40s, FORTRAN and COBOL in the 50s, BASIC and PL/I in the 60s, C and Prolog in the 70s,
among many other programming languages, like the ones to process and manage databases. The
80s have brought more advances, notably object-oriented programming languages like C++ and
Objective-C. In the 90s, the development of programming languages was influenced heavily by
the Internet revolution. Some of the most notable programming languages were Visual Basic, Java,
JavaScript, and PHP. The evolution of programming languages continued in the twenty and
twenty-one century with increasing trends toward security and reliability verification, concurrency
and massive parallelism, distribution and mobility, graphical interfaces, more integration with
databases including XML and relational databases. One of the most notable programming
languages of the modern era is C-Sharp (C#). C# is becoming very popular among programmers
for its productive environment, which is called the .NET Framework. The .NET Framework consists
of ready to use classes that are well written and well documented. They are handy for beginner
and professional programmers alike.
Computers are made to process all sorts of data. Writing good software is an art that involves
many steps. One of these steps is the design and implementation of data structures.
This book comes to achieve this goal; to design and implement data structures that we can use in
applications. The approach used in this book is very practical. Real-life applications have been
explained and developed gradually from scratch with an emphasis on the different types of data
structures. This book comes full of figures and examples that aid the student in understanding the
concepts of data structures. It contains many MC exercises and programming exercises that are
useful for students to help them master the topics. It is the first data structures book that is written
in both English and Arabic languages, side-by-side. It is the first data structures book that presents
examples in three programming languages, C++, C#, and Java. It is a unique, multi-language book
by all meanings.
The first chapter consists of several sections aimed at identifying basic concepts of ICT in terms of
hardware and software. It also addresses the basic fundaments of data structures. As well as the
mechanism of problem solving and software development, accompanied by a real-life case study.
The second chapter provides a brief tutorial of the main concepts and structures of the C++, C#,
and Java programming languages that we use throughout this book. It starts by pointing out the
advantages of using these programming languages. It has a section devoted to each language.
We introduce each one of the three programming languages, and we present their traits and
peculiarities. The best development tools for each language has been discussed and then shown
how to download them, install them, and use them. Finally, we present a comparison of the three
programming languages via some examples, which we show in detail. This section does not cover
the three programming languages in detail; instead, it covers the necessary material needed for
the rest of the chapters.
The third chapter presents arrays in general and arrays of objects in particular. Arrays of objects
are one of the building blocks in data structures. It is crucial to understand this subject before
moving any farther. The chapter ends with covering step-by-step the utilization of the arrays of
objects in the real-life case study. The fourth chapter presents linked lists, which are the other
vii
Practical Data Structures with C++, C#, and Java
building block in data structures. It presents the primary operations performed on linked lists, such
as adding and deleting objects in linked lists, searching, and printing the content of these objects.
It covers other types of linked lists, such as circular and doubly-linked lists. At the end of the chapter,
it shows how to switch from arrays to linked lists in detail via the case study. In the fifth chapter to
the eighth chapter, we present and cover the various types of data structures, namely stacks,
queues, trees, and graphs in detail. These are the primary data structures that make up most of
this book. Each chapter provides definitions and examples to advance the understanding of each
of these data structures. Also, the implementations of these structures using arrays and linked lists
are presented and worked out. Finally, many examples demonstrate how these data structures are
used in real-life applications.
Associate Professor
viii
M.A. Eljinini
1
Practical Data Structures with C++, C#, and Java
1.1 INTRODUCTION
This chapter aims to present the fundament ﺗﻬﺩﻑ ﺍﻟﻭﺣﺩﺓ ﺍﻻﻭﻟﻰ ﺇﻟﻰ ﺍﻟﺗﻌﺭﻑ ﻋﻠﻰ ﺍﻟﻣﻔﺎﻫﻳﻡ ﺍﻷﺳﺎﺳﻳﺔ ﻓﻲ ﻫﻳﺎﻛﻝ
concepts of data structures, its types, and ﺍﻟﺑﻳﺎﻧﺎﺕ ﻭﻋﻠﻰ ﺃﻧﻭﺍﻋﻬﺎ ﻭﺍﺳﺗﺧﺩﺍﻣﺎﺗﻬﺎ ﻓﻲ ﺗﻛﻧﻭﻟﻭﺟﻳﺎ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ .ﻫﺫﻩ
usages in the field of Information Technology. ﺍﻟﻭﺣﺩﺓ ﺳﺗﻛﻭﻥ ﺗﻣﻬﻳﺩﺍ ﺇﻟﻰ ﺑﺎﻗﻲ ﺍﻟﻭﺣﺩﺍﺕ ﻛﻣﺎ ﺳﺗﻛﻭﻥ ﻣﺩﻋﻣﺔ ﺑﺎﻷﻣﺛﻠﺔ
First, we give a brief description of the rest of the ﺍﻟﻭﺍﻗﻌﻳﺔ ﻭﺍﻟﺗﻲ ﺳﺗﻌﺯﺯ ﻣﻥ ﺗﻭﺿﻳﺢ ﺍﻟﻣﻔﺎﻫﻳﻡ ﺍﻷﺳﺎﺳﻳﺔ ﻓﻲ ﺗﻁﻭﻳﺭ
chapters of this book. We then present some ﺍﻟﺑﺭﻣﺟﻳﺎﺕ ﺑﺷﻛﻝ ﻋﺎﻡ ﻭﻫﻳﺎﻛﻝ ﺍﻟﺑﻳﺎﻧﺎﺕ ﺑﺷﻛﻝ ﺧﺎﺹ.
examples that explain the main concepts of ﻓﻲ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺛﺎﻧﻳﺔ ﺳﻳﺗﻡ ﻋﺭﺽ ﻣﻘﺩﻣﺔ ﻓﻲ ﻟﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ ﺍﻟﺳﻲ ، ++
software production in general and data ﻭﺍﻟﺳﻲ ، #ﻭﺍﻟﺟﺎﻓﺎ ﻭﺍﻟﺗﻲ ﺳﻧﺳﺗﺧﺩﻣﻬﺎ ﺧﻼﻝ ﺷﺭﺣﻧﺎ ﻟﻣﺎﺩﺓ ﻫﻳﺎﻛﻝ
structures in specific. ﺍﻟﺑﻳﺎﻧﺎﺕ .ﺗﻡ ﺍﺧﺗﻳﺎﺭ ﻫﺫﻩ ﺍﻟﻠﻐﺎﺕ ﺍﻟﺛﻼﺛﺔ ﻟﻠﻌﺩﻳﺩ ﻣﻥ ﺍﻷﺳﺑﺎﺏ ،ﻓﻬﻲ
C-Plus-Plus (C++), C-Sharp (C#), and Java are ﺟﻣﻳﻌﻬﺎ ﻟﻐﺎﺕ ﻛﺎﺋﻧﻳﺔ ﺍﻟﻣﻧﺣﻰ ﺃﻱ ﺃﻧﻬﺎ ﺗﻌﺗﻣﺩ ﻋﻠﻰ ﺗﺻﻧﻳﻑ ﺍﻷﺷﻳﺎء ﻓﻲ
the languages that we use throughout this book ﻛﺗﺎﺑﺔ ﺍﻟﺑﺭﺍﻣﺞ ﻭﺍﻟﺗﻲ ﺗﻛﻭﻥ ﺃﻗﺭﺏ ﺇﻟﻰ ﺍﻟﻭﺍﻗﻊ .ﻭﻣﻥ ﻓﻭﺍﺋﺩ ﻫﺫﻩ ﺍﻟﻠﻐﺎﺕ
to explain the subject of data structures. All three ﺃﻧﻬﺎ ﻣﺗﻌﺩﺩﺓ ﺍﻟﻣﻧﺻﺎﺕ ﺃﻱ ﺃﻥ ﺍﻟﺑﺭﺍﻣﺞ ﺍﻟﺗﻲ ﺗﻛﺗﺏ ﻳﻣﻛﻥ ﺗﻧﻔﻳﺫﻫﺎ ﻋﻠﻰ ﺃﻱ
computer languages are used in the teaching of ﻧﻅﺎﻡ ﻛﻭﻳﻧﺩﻭﺯ ﺃﻭ ﻟﻳﻧﻛﺱ ﺃﻭ ﻏﻳﺭﻫﺎ ﺩﻭﻥ ﺍﻟﺣﺎﺟﺔ ﺇﻟﻰ ﺇﻋﺎﺩﺓ ﻛﺗﺎﺑﺗﻬﺎ .ﺇﻥ
computer programming in many universities ﻏﺎﻟﺑﻳﺔ ﻛﻠﻳﺎﺕ ﺗﻛﻧﻭﻟﻭﺟﻳﺎ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻓﻲ ﺍﻟﺟﺎﻣﻌﺎﺕ ،ﻣﺣﻠﻳﺎ ﻭﻋﺭﺑﻳﺎ ﻭﺣﺗﻰ
around the world. ﻋﺎﻟﻣﻳﺎ ﺗﻌﺗﻣﺩ ﻟﻐﺔ ﺃﻭ ﺃﻛﺛﺭ ﻣﻥ ﻫﺫﻩ ﺍﻟﻠﻐﺎﺕ ﺍﻟﺛﻼﺛﺔ ﻛﻣﺎﺩﺓ ﺃﺳﺎﺳﻳﺔ ﻣﺳﺗﺧﺩﻣﺔ
In chapter 2, we provide a tutorial of the main ﻓﻲ ﺗﻌﻠﻡ ﺍﻟﺑﺭﻣﺟﺔ ﻭﻓﻲ ﻋﻣﻝ ﺍﻟﺗﻁﺑﻳﻘﺎﺕ ﻟﻣﻭﺍﺩ ﺍﻟﺣﺎﺳﻭﺏ ﺍﻷﺧﺭﻯ،
concepts and structures of these programming ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ ﺍﺳﺗﺧﺩﺍﻣﺎﺗﻬﺎ ﺍﻟﺷﺎﺋﻌﺔ ﻓﻲ ﺃﺳﻭﺍﻕ ﺍﻟﻌﻣﻝ ﺍﻟﻣﺣﻠﻳﺔ ﻭﺍﻟﻌﺎﻟﻣﻳﺔ.
languages. In chapter 3, we present arrays in ﻭﻣﻥ ﻓﻭﺍﺋﺩ ﻫﺫﻩ ﺍﻟﻠﻐﺎﺕ ﺃﻧﻪ ﻳﻣﻛﻥ ﺭﺑﻁ ﺍﻟﺑﺭﺍﻣﺞ ﺍﻟﺗﻲ ﻧﻁﻭﺭﻫﺎ ﻣﻊ ﺃﻧﻅﻣﺔ
general and arrays of objects in particular. ﻗﻭﺍﻋﺩ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻣﺛﻝ ﻣﺎﻳﻛﺭﻭﺳﻭﻓﺕ ﺃﻛﺳﺱ ﻭﺃﻭﺭﺍﻛﻝ ﻭﻣﺎﻱ-ﺇﺱ-ﻛﻳﻭ-ﺇﻝ
Arrays of objects are one of the building blocks ﻭﻏﻳﺭﻫﺎ .ﻭﻫﻧﺎ ﻳﺟﺩﺭ ﺍﻹﺷﺎﺭﺓ ﺇﻟﻰ ﺍﻧﻪ ﻳﻣﻛﻥ ﺍﻟﺣﺻﻭﻝ ﻋﻠﻳﻬﺎ ﺟﻣﻳﻌﺎ ﻣﺟﺎﻧﺎ
in data structures. It is very important to ﺩﻭﻥ ﺍﻟﺣﺎﺟﺔ ﺇﻟﻰ ﺩﻓﻊ ﺃﻱ ﻣﺑﻠﻎ ﻣﻥ ﺍﻟﻣﺎﻝ ﻻﺳﺗﺧﺩﺍﻣﻬﺎ .ﻓﻔﻲ ﻫﺫﺍ ﺍﻟﻛﺗﺎﺏ
understand this subject before moving any ﺗﻡ ﺍﻋﺗﻣﺎﺩ ﺗﻁﺑﻳﻖ ﻓﻳﺟﻭﺍﻝ ﺳﺗﻭﺩﻳﻭ ﻟﺗﻁﻭﻳﺭ ﺑﺭﺍﻣﺞ ﺳﻲ ++ﻭﺳﻲ ،#ﺣﻳﺙ
farther. In chapter 4, we present linked lists, ﻳﻣﻛﻥ ﺍﻟﺣﺻﻭﻝ ﻋﻠﻰ ﻧﺳﺧﺔ ﺍﻛﺳﺑﺭﻳﺱ ﺃﻭ ﻛﻭﻣﻳﻭ ﻧﻳﺗﻲ ﻋﻥ ﻁﺭﻳﻖ ﻣﻭﻗﻊ
which are another building block in data ﻣﺎﻳﻛﺭﻭﺳﻭﻓﺕ ﻣﺟﺎﻧﺎ .ﻛﻣﺎ ﻳﻭﺟﺩ ﻋﺩﺩ ﻛﺑﻳﺭ ﻣﻥ ﺍﻟﻣﺻﺎﺩﺭ ﻭﺍﻟﻣﺭﺍﺟﻊ
structures. In chapter 5 to chapter 8, we present ﻋﻠﻰ ﺍﻟﺷﺑﻛﺔ ﺍﻟﻌﻧﻛﺑﻭﺗﻳﺔ ﻭﺍﻟﻣﺗﺧﺻﺻﺔ ﻟﻬﺫﻩ ﺍﻟﻠﻐﺎﺕ ﻭﺍﻟﺗﻲ ﻳﻣﻛﻥ ﺍﻟﺭﺟﻭﻉ
Stacks, Queues, Trees, and Graphs ﺇﻟﻳﻬﺎ ﻟﻠﺣﺻﻭﻝ ﻋﻠﻰ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻭﺍﻟﻣﻭﺍﺩ ﺍﻟﺗﻌﻠﻳﻣﻳﺔ ﻭﺍﻟﺗﻲ ﺗﻧﺎﺳﺏ ﺟﻣﻳﻊ
respectively. These are the main data structures ﺍﻟﻣﺳﺗﻭﻳﺎﺕ .ﺗﺗﺿﻣﻥ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺛﺎﻧﻳﺔ ﺍﻷﺳﺎﺳﻳﺎﺕ ﻓﻲ ﻟﻐﺎﺕ ﺍﻟﺳﻲ++
that make up most of this book. We provide a ﻭﺍﻟﺳﻲ #ﻭﺍﻟﺟﺎﻓﺎ ،ﻭﺳﺗﻛﻭﻥ ﻫﺫﻩ ﺍﻟﻭﺣﺩﺓ ﻣﻘﺩﻣﺔ ﻟﻠﻭﺣﺩﺓ ﺍﻟﺛﺎﻟﺛﺔ ﻭﺍﻟﺗﻲ
definition of each one of them, and then we give ﺳﻧﺳﺗﻌﺭﺽ ﻓﻳﻬﺎ ﻣﻭﺿﻭﻉ ﺍﻟﻣﺻﻔﻭﻓﺎﺕ ﺑﺷﻛﻝ ﻋﺎﻡ ﻭﺍﻟﻣﺻﻔﻭﻓﺎﺕ ﻣﻥ
some examples to advance our understanding of ﺍﻟﻛﺎﺋﻧﺎﺕ ﺑﺷﻛﻝ ﺧﺎﺹ .ﺗﻌﺗﺑﺭ ﺍﻟﻣﺻﻔﻭﻓﺎﺕ ﺍﻟﻣﻛﻭﻧﺔ ﻣﻥ ﺍﻟﻛﺎﺋﻧﺎﺕ
each of these data structure. We show how we ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ ﺍﻟﻘﻭﺍﺋﻡ ﺍﻟﻣﺗﺭﺍﺑﻁﺔ ﺇﺣﺩﻯ ﺍﻟﻠﺑﻧﺎﺕ ﺍﻻﺳﺎﺳﻳﺔ ﻓﻲ ﻣﺎﺩﺓ ﻫﻳﺎﻛﻝ
use them in our programs; first, we implement ﺍﻟﺑﻳﺎﻧﺎﺕ ﻭﺍﻟﺗﻲ ﺳﻳﺗﻡ ﺍﻟﺗﺭﻛﻳﺯ ﻋﻠﻳﻬﺎ ﻓﻲ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺭﺍﺑﻌﺔ .ﺃﻣﺎ ﺍﻟﻭﺣﺩﺍﺕ
these data structures using arrays and then ﺍﻟﺧﺎﻣﺳﺔ ﺇﻟﻰ ﺍﻟﺛﺎﻣﻧﺔ ﻓﺳﻧﺳﺗﻌﺭﺽ ﻓﻳﻬﺎ ﺍﻟﻣﻛﺩﺳﺎﺕ ﻭﺍﻟﻁﻭﺍﺑﻳﺭ ﻭﺍﻻﺷﺟﺎﺭ
linked lists. Finally, we provide more real-life ﻭﺍﻟﻣﺧﻁﻁﺎﺕ ﻋﻠﻰ ﺍﻟﺗﻭﺍﻟﻲ .ﺗﺑﺩﺃ ﻛﻝ ﻭﺣﺩﺓ ﺑﺎﻟﺗﻌﺭﻳﻑ ﻋﻥ ﻫﻳﻛﻠﺔ ﺍﻟﺑﻳﺎﻧﺎﺕ
examples and show how these data structures ﻭﻣﻥ ﺛﻡ ﻋﺭﺽ ﺃﻣﺛﻠﺔ ﺑﺳﻳﻁﺔ ،ﺛﻡ ﻧﻌﺭﺽ ﻛﻳﻔﻳﺔ ﺑﺭﻣﺟﺔ ﻛﻝ ﻣﻥ ﻫﻳﺎﻛﻝ
are used in real-life applications. ﺍﻟﺑﻳﺎﻧﺎﺕ ﺑﺎﺳﺗﺧﺩﺍﻡ ﺍﻟﻣﺻﻔﻭﻓﺎﺕ ﺃﻭﻻ ﻭﻣﻥ ﺛﻡ ﺑﺎﺳﺗﺧﺩﺍﻡ ﺍﻟﻘﻭﺍﺋﻡ ﺍﻟﻣﺗﺭﺍﺑﻁﺔ
ﻭﺑﻠﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ ﺍﻟﺛﻼﺛﺔ .ﻓﻲ ﻧﻬﺎﻳﺔ ﻛﻝ ﻭﺣﺩﺓ ﻧﻌﺭﺽ ﺃﻣﺛﻠﺔ ﻭﺍﻗﻌﻳﺔ
ﻭﺗﻁﺑﻳﻘﺎﺕ ﻋﺩﻳﺩﺓ.
Data Structures is about organizing, managing, and storing our ﺇﻥ ﻫﻳﺎﻛﻝ ﺍﻟﺑﻳﺎﻧﺎﺕ ﺗﻌﻧﻰ ﺑﺗﻧﻅﻳﻡ ﻭﺇﺩﺍﺭﺓ ﻭﻫﻳﻛﻠﺔ
data efficiently. Our programs usually reserve space for our data ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ،ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ
in the main memory of the computer. The Main Memory is also ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﺗﻲ ﺗﻘﻭﻡ ﻋﻠﻳﻬﺎ ،ﻭﺫﻟﻙ ﺑﻘﺻﺩ
called Radom Access Memory (RAM). Data structures is about ﺍﺳﺗﺧﺩﺍﻣﻬﺎ ﺑﺷﻛﻝ ﻓﺎﻋﻝ ﺟﺩﺍ .ﻣﻥ ﺍﻟﻌﻠﻣﻳﺎﺕ ﺍﻟﺗﻲ
structuring and processing our data, which we will use in our ﻳﺗﻡ ﺗﻧﻔﻳﺫﻫﺎ ﻋﻠﻰ ﺍﻟﺑﻳﺎﻧﺎﺕ ﺍﻟﺣﻔﻅ ،ﻭﺍﻻﺳﺗﺭﺟﺎﻉ،
programs in very efficient ways. We will learn how to store and ﻭﺍﻟﺗﻌﺩﻳﻝ ،ﻭﺍﻟﺑﺣﺙ .ﻓﻌﻧﺩﻣﺎ ﻧﻧﻔﺫ ﺃﻱ ﺑﺭﻧﺎﻣﺞ ﻓﺈﻧﻪ
retrieve our data, how to update it, and even how to search for ﻳﻘﻭﻡ ﺑﺣﺟﺯ ﺟﺯء ﻣﻥ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ﺍﻟﺭﺋﻳﺳﻳﺔ
items. Figure 1-1 shows the main reason for using computers, ﻟﻠﺑﻳﺎﻧﺎﺕ ﺍﻟﺗﻲ ﻳﻌﺎﻟﺟﻬﺎ .ﺍﻟﺷﻛﻝ 1-1ﻳﻌﺭﺽ
which is to process our data into useful information. Our data may ﺍﻟﻬﺩﻑ ﺍﻟﺭﺋﻳﺳﻲ ﻣﻥ ﺍﻟﺣﺎﺳﻭﺏ ﻭﻫﻭ ﻣﻌﺎﻟﺟﺔ
take several forms like numbers, characters, words, text, and ﺍﻟﺑﻳﺎﻧﺎﺕ .ﺇﻥ ﻫﺫﻩ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻗﺩ ﺗﺄﺧﺫ ﺃﺷﻛﺎﻻ ﻣﺧﺗﻠﻔﺔ
even images and sounds.
2
M.A. Eljinini
3
Practical Data Structures with C++, C#, and Java
computer, and then it prepares the user interface (UI) that is ﻭﺑﻌﺩ ﺫﻟﻙ ﻳﻘﻭﻡ ﻫﺫﺍ ﺍﻟﺟﺯء ﻭﺍﻟﺫﻱ ﻳﻛﻭﻥ.ﺍﻟﺭﺋﻳﺳﻳﺔ
the desktop. ﻋﺎﺩﺓ ﻣﻭﺟﻭﺩ ﻋﻠﻰ ﺍﻟﻘﺭﺹ ﺍﻟﺻﻠﺏ ﺑﺎﻟﻌﻣﻝ ﻋﻠﻰ
ﺗﻧﻅﻳﻡ ﻋﻣﻝ ﺍﻟﺣﺎﺳﻭﺏ ﻭﺍﻟﺗﺣﻛﻡ ﻓﻳﻪ ﻭﺗﻁﻭﻳﻌﻪ
Once it is ready, it silently waits for us to interact with the .ﻟﻠﻣﺳﺗﺧﺩﻡ ﻟﻼﺳﺗﻔﺎﺩﺓ ﻣﻧﻪ ﺑﺎﻟﺷﻛﻝ ﺍﻟﻣﻧﺎﺳﺏ
computer. For example, if we want to use the calculator, we ﻓﻌﻧﺩﻣﺎ ﻧﺭﻳﺩ ﺗﺷﻐﻳﻝ ﺑﺭﻧﺎﻣﺞ ﺍﻵﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ ﻣﺛﻼ ﻓﺈﻧﻧﺎ
double click on its icon. We are commanding the operating ﻧﻘﻭﻡ ﺑﺎﻟﻧﻘﺭ ﺑﺎﻟﻔﺄﺭﺓ ﻋﻠﻰ ﺍﻷﻳﻘﻭﻧﺔ ﺍﻟﻣﺧﺻﺻﺔ ﻟﻶﻟﺔ
system to start the calculator for us. The OS does that by ﻭﻛﺄﻧﻧﺎ ﻧﺧﺎﻁﺏ ﻧﻅﺎﻡ ﺍﻟﺗﺷﻐﻳﻝ ﻭﻧﻁﻠﺏ ﻣﻧﻪ،ﺍﻟﺣﺎﺳﺑﺔ
loading a copy of the calculator program, which resides ﻓﻳﻘﻭﻡ ﻧﻅﺎﻡ ﺍﻟﺗﺷﻐﻳﻝ ﺑﺩﻭﺭﻩ.ﺗﺷﻐﻳﻝ ﺍﻵﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ ﻟﻧﺎ
originally on the hard disk into the main memory. To be more ﺑﺗﺣﻣﻳﻝ ﻧﺳﺧﺔ ﻣﻥ ﺑﺭﻧﺎﻣﺞ ﺍﻵﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ ﺇﻟﻰ ﺍﻟﻣﻛﺎﻥ
specific, it loads the copy into a special place called the code ﺍﻟﻣﺧﺻﺹ ﻓﻲ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ﺍﻟﻌﺷﻭﺍﺋﻳﺔ ﻳﺳﻣﻰ
segment, as shown in figure 1-2. ﻗﺳﻡ ﺍﻟﺷﻳﻔﺭﺓ ﺣﻳﺙ ﻳﺗﻡ ﺍﻟﺗﻧﻔﻳﺫ ﻋﻥ ﻁﺭﻳﻖ ﺍﻧﺗﻘﺎﻝ
ﺍﻷﻭﺍﻣﺭ ﻣﻥ ﻗﺳﻡ ﺍﻟﺷﻳﻔﺔ ﺇﻟﻰ ﻭﺣﺩﺓ ﺍﻟﻣﻌﺎﻟﺟﺔ ﺍﻟﻣﻌﺎﻟﺞ
Once the OS loads the calculator program into memory, the .ﺍﻟﻣﺭﻛﺯﻳﺔ ﺑﺳﺭﻋﺔ ﻓﺎﺋﻘﺔ
lines of the code that are called instructions are fetched into
the CPU one by one. The CPU is connected directly to the ﻭﻣﻥ ﻫﺫﻩ ﺍﻷﻭﺍﻣﺭ ﺗﻬﻳﺋﺔ ﺷﻛﻝ ﺍﻵﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ ﻋﻠﻰ
memory; it receives instructions and performs the required ﺷﺎﺷﺔ ﺳﻁﺢ ﺍﻟﻣﻛﺗﺏ ﻛﻲ ﻧﺗﻔﺎﻋﻝ ﻣﻌﻬﺎ ﻋﻧﺩ
tasks. Like any program, the calculator first prepares its user ﺍﻻﺳﺗﺧﺩﺍﻡ ﻭﺃﻳﺿﺎ ﺣﺟﺯ ﻣﻛﺎﻥ ﻓﻲ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ
interface that is the window with the display and the buttons ﻭﻫﺫﻩ. ﻭﻫﺫﺍ ﺍﻟﻣﻛﺎﻥ ﻳﺳﻣﻰ ﻗﺳﻡ ﺍﻟﺑﻳﺎﻧﺎﺕ،ﻟﻠﺑﻳﺎﻧﺎﺕ
containing numbers and operations. After that, it waits for us ﺍﻟﺑﻳﺎﻧﺎﺕ ﻫﻲ ﺍﻷﻋﺩﺍﺩ ﺍﻟﺗﻲ ﺳﻧﺩﺧﻠﻬﺎ ﻻﺳﺗﺧﺩﺍﻣﻬﺎ ﻓﻲ
to start using it. We do that by entering numbers and ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﺣﺳﺎﺑﻳﺔ ﻭﻣﻥ ﺛﻡ ﺇﻅﻬﺎﺭ ﺍﻟﻧﺗﺎﺋﺞ ﻓﻲ ﺍﻟﻣﻛﺎﻥ
operations to perform the calculations. The numbers we enter .ﺍﻟﻣﺧﺻﺹ ﻟﻬﺎ ﻋﻠﻰ ﺍﻟﺷﺎﺷﺔ
for calculation is data that goes into a special place in the main
memory called the data segment. How does the calculator ﺇﺫﺍ ً ﻛﻳﻑ ﻳﻘﻭﻡ ﺑﺭﻧﺎﻣﺞ ﺍﻵﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ ﺑﺣﺟﺯ ﻣﻛﺎﻧﺎ
program reserve a space for this data in memory? In other ﻟﻬﺫﻩ ﺍﻟﺑﻳﺎﻧﺎﺕ ﺃﻱ ﺑﻣﻌﻧﻰ ﺁﺧﺭ ﻛﻳﻑ ﻳﻘﻭﻡ ﺑﻬﻳﻛﻠﺔ
words, how does the program structure the data in memory? If ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺍﻟﺫﺍﻛﺭﺓ؟ ﻭﺇﺫﺍ ﺃﺭﺩﻧﺎ ﺃﻥ ﻧﺑﺭﻣﺞ ﺁﻟﺔ
we are going to code our programs, how do we deal with the ﺣﺎﺳﺑﺔ ﺑﺄﻧﻔﺳﻧﺎ ﺃﻭ ﺃﻱ ﺑﺭﻧﺎﻣﺞ ﺁﺧﺭ ﻓﻛﻳﻑ ﻧﺗﻌﺎﻣﻝ ﻣﻊ
different types of data such as numbers and text? We shall ﺍﻷﻧﻣﺎﻁ ﺍﻟﻣﺧﺗﻠﻔﺔ ﻣﻥ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻣﺛﻝ ﺍﻷﻋﺩﺍﺩ
present these matters in detail in the next chapter. .ﻭﺍﻟﻧﺻﻭﺹ ﻭﻏﻳﺭﻫﺎ؟ ﻫﺫﺍ ﻣﺎ ﺳﻧﻘﻭﻡ ﺑﺷﺭﺣﻪ ﻻﺣﻘﺎ
4
M.A. Eljinini
According to the ASCII table, each code is made of seven ﻳﺳﻣﻰ ﻫﺫﺍ ﺍﻟﺟﺩﻭﻝ ﺑﺟﺩﻭﻝ ﺍﻟﺭﻣﻭﺯ ﺍﻷﻣﺭﻳﻛﻳﺔ ﺍﻟﻘﻳﺎﺳﻳﺔ
digits of zeros and ones. If we convert a series of seven ﻓﻛﻝ ﺭﻣﺯ ﻳﺗﺄﻟﻑ ﻣﻥ ﺳﺑﻊ ﺧﺎﻧﺎﺕ ﺃﻱ ﻣﻥ.ﻟﺗﺑﺎﺩﻝ ﺍﻟﺑﻳﺎﻧﺎﺕ
ones to a decimal value, we get the value 127. ﻣﻥ128 ﻭﺑﺫﻟﻙ ﻳﺳﻣﺢ ﻫﺫﺍ ﺍﻟﺟﺩﻭﻝ ﺑﺗﻣﺛﻳﻝ127 ﺇﻟﻰ0
Therefore, we have a range from 0 to 127 different values ﺍﻟﺭﻣﻭﺯ ﻭﺍﻟﺗﻲ ﻛﺎﻧﺕ ﻓﻲ ﺑﺩﺍﻳﺎﺕ ﻋﻬﺩ ﺍﻟﺣﻭﺍﺳﻳﺏ ﻛﺎﻓﻳﺔ
that the ASCII table can represent. This was enough ﻟﺗﻐﻁﻳﺔ ﺟﻣﻳﻊ ﺍﻟﺣﺭﻭﻑ ﺍﻟﻣﺳﺗﻌﻣﻠﺔ ﺣﻳﺙ ﻛﺎﻧﺕ ﺍﻟﻠﻐﺔ
values for early computers to cover all the used symbols, ﻭﻣﻊ.ﺍﻻﻧﺟﻠﻳﺯﻳﺔ ﻫﻲ ﺍﻟﻭﺣﻳﺩﺓ ﺍﻟﻣﻌﺗﻣﺩﺓ ﻓﻲ ﺃﻧﻅﻣﺔ ﺍﻟﺣﺎﺳﻭﺏ
taking into consideration that the English Language was ﺍﻟﺗﻁﻭﺭ ﺍﻟﻌﺎﻟﻣﻲ ﻓﻲ ﺍﺳﺗﺧﺩﺍﻣﺎﺕ ﺍﻟﺣﺎﺳﻭﺏ ﺃﺻﺑﺢ ﻻ ﺑﺩ ﻣﻥ
the only language used at that time. During the years, ﺑﺎﻹﺿﺎﻓﺔ،ﺗﻭﺳﻳﻊ ﺍﻟﺟﺩﻭﻝ ﻟﻳﺷﻣﻝ ﺍﻟﻠﻐﺎﺕ ﺍﻟﻌﺎﻟﻣﻳﺔ ﺍﻷﺧﺭﻯ
many coding systems have been developed to handle ﻭﻓﻲ ﺑﺩﺍﻳﺔ ﺍﻟﺗﺳﻌﻳﻧﺎﺕ ﺗﻡ،ﺇﻟﻰ ﺑﻌﺽ ﺍﻟﺭﻣﻭﺯ ﻭﺍﻷﺷﻛﺎﻝ
text in so many different languages across the globe. In ﺇﻧﺷﺎء ﺟﺩﻭﻝ ﺍﻟﺭﻣﺯ ﺍﻟﻣﻭﺣﺩ ﻭﺍﻟﺫﻱ ﻳﺣﺗﻭﻱ ﻋﻠﻰ ﺃﻻﻑ
the early nineties, a new coding system called Unicode .ﺍﻟﺭﻣﻭﺯ ﻭﻣﻧﻬﺎ ﺭﻣﻭﺯ ﻟﻸﺣﺭﻑ ﺍﻟﻌﺭﺑﻳﺔ
was developed which contains thousands of symbols that
can handle most written text such as Arabic.
We have mentioned earlier that the bit is
the smallest unit of data that can hold one
of two values. A larger unit is the byte,
which consists of eight bits.
Today most computers use 64-bit
architecture. Data moves from memory to
the CPU in a path called the data bus with
a width of 64 bits (8 bytes). Therefore, the
memory is made of groups of cells; each
consists of 64 bits. A group of 64 bits is
equal to one word, and each word in the
computer memory has an address.
Imagine that the memory of the computer
consists of boxes where each box is
labeled with an address and can hold 64
bits of data. One of the main tasks we do
when writing computer programs is
reserving memory spaces for our data,
which are called variables. For example, if Figure 1-3: ASCII Table
we want to write a small program for
adding any two numbers, we need to do ﻭﻣﻥ ﺍﻟﻭﺣﺩﺍﺕ ﺍﻷﺧﺭﻯ ﺍﻟﺗﻲ ﻳﺗﻡ ﺍﻟﺗﻌﺎﻣﻝ ﻣﻌﻬﺎ ﻓﻲ ﺃﻧﻅﻣﺔ ﺍﻟﺣﺎﺳﻭﺏ ﻟﻔﻬﻡ ﺍﻟﺑﻳﺎﻧﺎﺕ
the following steps: . ﺑﺕ8 ﻫﻲ ﺍﻟﺑﺎﻳﺕ ﻭﺍﻟﺗﻲ ﺗﺳﺎﻭﻱ
1. Declare three variables and give them
meaningful names. For example, ﺇﻥ ﻣﻌﻅﻡ ﺃﺟﻬﺯﺓ ﺍﻟﺣﺎﺳﻭﺏ ﻓﻲ ﺃﻳﺎﻣﻧﺎ ﻫﺫﻩ ﻣﺯﻭﺩﻩ ﺑﺫﺍﻛﺭﺓ ﺣﻳﺙ ﺃﻥ ﺳﻌﺔ ﺍﻟﻣﻣﺭ
num1, num2, and result. ﺑﺕ ﺑﻧﻔﺱ64 ﺃﻱ ﺍﻧﻬﺎ ﻗﺎﺩﺭﺓ ﻋﻠﻰ ﻧﻘﻝ،( ﺑﺎﻳﺕ8) ﺑﺕ64 ﺍﻟﻧﺎﻗﻝ ﻟﻠﺑﻳﺎﻧﺎﺕ ﻓﻳﻬﺎ
2. Define their types based on user ﻭﻳﻣﻛﻥ ﺍﻟﻘﻭﻝ ﺇﻥ ﺍﻟﺫﺍﻛﺭﺓ ﻣﻘﺳﻣﺔ ﺇﻟﻰ ﻣﺟﻣﻭﻋﺎﺕ ﻣﻥ.ﺍﻟﻭﻗﺕ ﻭﺑﺷﻛﻝ ﻣﺗﻣﺎﺛﻝ
requirements. For example, (int) for ﺗﺧﻳﻝ. ﻭﻟﻛﻝ ﻛﻠﻣﺔ ﻋﻧﻭﺍﻥ، ﺑﺕ ﻭﺗﺳﻣﻰ ﻛﻠﻣﺔ64 ﺍﻟﺧﻼﻳﺎ ﺳﻌﺔ ﻛﻝ ﻣﺟﻣﻭﻋﺔ ﻣﻧﻬﺎ
integers and (float) for real numbers. ﺃﻥ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ﻣﻘﺳﻣﺔ ﺇﻟﻰ ﺻﻧﺎﺩﻳﻖ ﻛﻝ ﺻﻧﺩﻭﻕ ﻳﺣﺗﻭﻱ ﻋﻠﻰ ﻛﻠﻣﺔ
We discuss data types in more detail in ﻓﻣﻥ ﺍﻷﺷﻳﺎء ﺍﻻﺳﺎﺳﻳﺔ ﻋﻧﺩ ﻛﺗﺎﺑﺔ.ﻭﻧﺳﺗﻁﻳﻊ ﺍﻟﻭﺻﻭﻝ ﺇﻟﻳﻬﺎ ﻋﻥ ﻁﺭﻳﻖ ﻋﻧﻭﺍﻧﻬﺎ
the next chapter. ﺍﻟﺑﺭﺍﻣﺞ ﻫﻭ ﺣﺟﺯ ﺃﻣﺎﻛﻥ ﻓﻲ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ﻟﻠﺑﻳﺎﻧﺎﺕ ﻭﺗﻛﻭﻥ ﻋﻠﻰ ﺷﻛﻝ
3. When our program runs, the operating ﻓﻣﺛﻼ ﺇﺫﺍ ﺃﺭﺩﻧﺎ ﻛﺗﺎﺑﺔ ﺑﺭﻧﺎﻣﺞ ﺑﺳﻳﻁ ﻳﻘﻭﻡ ﺑﺈﺩﺧﺎﻝ ﻋﺩﺩﻳﻥ ﺻﺣﻳﺣﻳﻥ.ﻣﺗﻐﻳﺭﺍﺕ
system reserves space for these ﻭﺟﻣﻌﻬﻣﺎ ﻭﻋﺭﺽ ﺍﻟﻧﺎﺗﺞ ﻓﺈﻧﻧﺎ ﻧﺣﺗﺎﺝ ﺇﻟﻰ ﺣﺟﺯ ﻣﻛﺎﻧﻳﻥ ﻟﻬﻣﺎ ﻓﻲ ﺍﻟﺫﺍﻛﺭﺓ
variables in the data segment of the (num2) 2( ﻭﻋﺩﺩnum1) 1( ﺃﻭ ﻋﺩﺩy) ( ﻭ ﺹx) ﻭﺗﺳﻣﻳﺗﻬﻣﺎ ﻣﺛﻼ ﺱ
main memory. ﻭﻋﻧﺩ،ﻭﺃﻳﺿﺎ ﻳﺟﺏ ﺍﻟﺗﺻﺭﻳﺢ ﺑﻧﻣﻁ ﻫﺫﻩ ﺍﻟﻣﺗﻐﻳﺭﺍﺕ ﺃﻱ ﻣﻥ ﻧﻭﻉ ﻋﺩﺩ ﺻﺣﻳﺢ
ﺗﻧﻔﻳﺫ ﺍﻟﺑﺭﻧﺎﻣﺞ ﻳﻘﻭﻡ ﻧﻅﺎﻡ ﺍﻟﺗﺷﻐﻳﻝ ﺑﺗﺣﻣﻳﻝ ﺍﻟﺑﺭﻧﺎﻣﺞ ﺇﻟﻰ ﺍﻟﻣﻛﺎﻥ ﺍﻟﻣﺧﺻﺹ ﻟﻪ
5
Practical Data Structures with C++, C#, and Java
4. After that, the program asks the user to ﻓﻲ ﺫﺍﻛﺭﺓ ﺍﻟﺣﺎﺳﻭﺏ ﻭﺑﻌﺩﻫﺎ ﻳﻁﻠﺏ ﺍﻟﺑﺭﻧﺎﻣﺞ ﻣﻥ ﻧﻅﺎﻡ ﺍﻟﺗﺷﻐﻳﻝ ﺗﺧﺻﻳﺹ ﻭﺣﺟﺯ
input two numbers, then perform the ﺍﻻﻣﺎﻛﻥ ﺍﻟﻼﺯﻣﺔ ﻟﻬﺫﻳﻥ ﺍﻟﻣﺗﻐﻳﺭﻳﻥ ﻓﻲ ﺍﻟﻣﻛﺎﻥ ﺍﻟﻣﺧﺻﺹ ﻟﺣﺟﺯ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ
addition and display the result. ﻭﻳﻘﻭﻡ ﺍﻟﻧﻅﺎﻡ ﺑﺈﺭﺟﺎﻉ ﺍﻟﻌﻧﺎﻭﻳﻥ ﺇﻟﻰ ﺍﻟﺑﺭﻧﺎﻣﺞ ﻛﻣﺭﺟﻊ ﻳﺗﻌﺎﻣﻝ ﻣﻌﻪ ﻋﻧﺩ،ﺍﻟﺫﺍﻛﺭﺓ
ﺗﺧﺯﻳﻥ ﺍﻷﻋﺩﺍﺩ ﺍﻟﻣﺭﺍﺩ ﺟﻣﻌﻬﺎ ﻛﻣﺎ ﻓﻲ ﻫﺫﺍ ﺍﻟﻣﺛﺎﻝ ﻭﺍﻟﺫﻱ ﺳﻳﻘﻭﻡ ﺍﻟﻣﺳﺗﺧﺩﻡ
The data types (int) and (float) are called .ﺑﺈﺩﺧﺎﻟﻬﻣﺎ ﻻﺣﻘﺎ ﺧﻼﻝ ﻣﺭﺣﻠﺔ ﺍﻟﺗﻧﻔﻳﺫ
primitive data types. They are simple, and
we cannot divide them into smaller units.
On the other hand, arrays are more ﻳﻌﺗﺑﺭ ﺍﻟﻧﻣﻁ )ﻋﺩﺩ ﺻﺣﻳﺢ( ﻣﻥ ﺃﻧﻣﺎﻁ ﺍﻟﺑﻳﺎﻧﺎﺕ ﺍﻟﺑﺳﻳﻁﺔ ﺃﻭ ﺍﻟﺑﺩﺍﺋﻳﺔ ﻭﻫﻧﺎﻟﻙ ﺃﻧﻣﺎﻁ
complex data types that we discuss in ﺃﺧﺭﻯ ﻣﻧﻬﺎ ﻣﺛﻝ )ﺣﺭﻑ( ﻟﻠﺗﻌﺎﻣﻝ ﻣﻊ ﺍﻟﺣﺭﻭﻑ ﺑﺷﻛﻝ ﻣﻧﻔﺭﺩ ﻭﻧﻣﻁ )ﻋﺩﺩ
chapter three. ﻋﺷﺭﻱ( ﻭﻏﻳﺭﻫﺎ ﻭﺍﻟﺗﻲ ﺳﻧﻘﻭﻡ ﺑﻌﺭﺿﻬﺎ ﻓﻲ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺛﺎﻧﻳﺔ ﻋﻧﺩ ﺍﻟﺗﻛﻠﻡ ﻋﻥ ﻟﻐﺎﺕ
ﺃﻣﺎ ﺍﻟﻣﺻﻔﻭﻓﺎﺕ ﻓﻬﻲ ﻣﻥ ﺍﻷﻧﻣﺎﻁ ﺍﻟﻣﺭﻛﺑﺔ ﻭﺍﻟﺗﻲ ﺳﻧﻌﺭﺿﻬﺎ ﺑﺎﻟﺗﻔﺻﻳﻝ.ﺍﻟﺑﺭﻣﺟﺔ
.ﻓﻲ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺛﺎﻟﺛﺔ
1.4 SOFTWARE
Computer programs are groups of instructions that perform ﺑﺭﻣﺟﻳﺎﺕ ﺍﻟﺣﺎﺳﻭﺏ ﻫﻲ ﻋﺑﺎﺭﺓ ﻋﻥ ﻣﺟﻣﻭﻋﺎﺕ ﻣﻥ
particular tasks and are converted into machine language ﺍﻟﺗﻌﻠﻳﻣﺎﺕ ﺃﻭ ﺍﻷﻭﺍﻣﺭ ﻣﻛﺗﻭﺑﺔ ﺑﻠﻐﺔ ﺍﻵﻟﺔ ﻭﺗﻘﻭﻡ ﺑﻣﻬﺎﻡ
when they are executed. There are two major types of ﻧﻅﻡ ﺍﻟﺗﺷﻐﻳﻝ: ﻭﻫﻧﺎﻟﻙ ﻧﻭﻋﺎﻥ ﻣﻥ ﺍﻟﺑﺭﻣﺟﻳﺎﺕ.ﻣﻌﻳﻧﺔ
programs: Operating systems like Windows and Linux, ﻛﻧﻅﺎﻡ ﻭﻳﻧﺩﻭﺯ ﻭﻟﻳﻧﻛﺱ ﻭﻏﻳﺭﻫﺎ ﻭﺍﻟﺗﻲ ﺗﺗﺣﻛﻡ ﺑﺎﻟﻛﻳﺎﻥ
which are made to control the computer hardware and ﺍﻟﻣﺎﺩﻱ ﻟﻠﺣﺎﺳﻭﺏ ﻭﺗﻭﻓﺭ ﻟﻠﻣﺳﺗﺧﺩﻡ ﺑﻳﺋﺔ ﺗﻔﺎﻋﻠﻳﺔ ﻣﻊ
provide users with a productive environment for interacting ﻭﺍﻟﻧﻭﻉ ﺍﻟﺛﺎﻧﻲ ﻫﻲ ﺃﻧﻅﻣﺔ ﺗﻁﺑﻳﻘﺎﺕ ﺍﻟﺣﺎﺳﻭﺏ.ﺍﻟﺣﺎﺳﻭﺏ
and running programs. The other type is computer ﻭﻣﻧﻬﺎ ﺑﺭﻣﺟﻳﺎﺕ ﻣﻌﺎﻟﺟﺔ ﺍﻟﻧﺻﻭﺹ ﻭﺑﺭﻣﺟﻳﺎﺕ ﺗﺻﻔﺢ
applications, for example, there are applications for ﺍﻟﻭﻳﺏ ﻭﺑﺭﻣﺟﻳﺎﺕ ﻗﻭﺍﻋﺩ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻭﺑﺭﻣﺟﻳﺎﺕ ﺍﻷﻟﻌﺎﺏ
processing text, browsing the web, playing games, ﻭﻏﻳﺭﻫﺎ ﺍﻟﻛﺛﻳﺭ ﻭﺍﻟﺗﻲ ﺗﺳﺎﻋﺩ،ﻭﺑﺭﻣﺟﻳﺎﺕ ﺍﻻﻟﺔ ﺍﻟﺣﺎﺳﺑﺔ
searching databases, performing complex calculations, ﻭﻫﺫﻩ ﺍﻟﺑﺭﻣﺟﻳﺎﺕ ﻗﺎﻡ.ﺍﻹﻧﺳﺎﻥ ﻓﻲ ﺷﺗﻰ ﺍﻟﻣﺟﺎﻻﺕ
and just about anything that we may use in our daily lives. ﺑﺗﺻﻣﻳﻣﻬﺎ ﻭﺑﺭﻣﺟﺗﻬﺎ ﺃﺷﺧﺎﺹ ﻫﻡ ﻣﺑﺭﻣﺟﻭﻥ ﺍﺣﺗﺭﻓﻭﺍ
Computer programs are designed and implemented by ﻭﻋﺎﺩﺓ ﻳﻌﻣﻠﻭﻥ ﻓﻲ ﺷﺭﻛﺎﺕ ﻣﺗﺧﺻﺻﺔ،ﻣﻬﻧﺔ ﺍﻟﺑﺭﻣﺟﺔ
programmers. Programmers usually work for companies ﻣﺛﻝ ﺷﺭﻛﺔ ﻣﺎﻳﻛﺭﻭﺳﻭﻓﺕ ﻭﻏﻳﺭﻫﺎ ﺍﻟﻛﺛﻳﺭ ﻣﻥ ﺍﻟﺷﺭﻛﺎﺕ
like Microsoft and other international and local companies. . ﻭﺑﻌﺿﻬﻡ ﻳﻌﻣﻝ ﻟﺣﺳﺎﺑﻪ ﺍﻟﺧﺎﺹ،ﺍﻟﻌﺎﻟﻣﻳﺔ ﻭﺍﻟﻣﺣﻠﻳﺔ
Some programmers are freelancers who do work on their ﻭﻟﻛﻲ ﺗﺻﺑﺢ ﻣﺑﺭﻣﺟﺎ ﻣﺣﺗﺭﻓﺎ ﻻ ﺑﺩ ﻣﻥ ﺃﻥ ﺗﺗﻌﻠﻡ ﻣﻌﻣﺎﺭﻳﺔ
own. To become a professional programmer, we need to ﺍﻟﺣﺎﺳﻭﺏ ﻭﺑﺭﻣﺟﺗﻪ ﺑﺎﺳﺗﺧﺩﺍﻡ ﺇﺣﺩﻯ ﻟﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ ﻣﺛﻝ
learn computer hardware and software. We need to ﻭﻣﻧﻬﺎ ﻛﻳﻔﻳﺔ ﺍﻟﺗﻌﺎﻣﻝ ﻣﻊ، ﺃﻭ ﺟﺎﻓﺎ# ﺃﻭ ﺳﻲ++ﺳﻲ
become fluent with at least one programming language, ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺑﺭﻣﺟﻳﺎﺕ ﺍﻟﺣﺎﺳﻭﺏ ﺍﻟﺗﻲ ﺗﺻﻣﻣﻬﺎ ﻭﺗﻛﺗﺑﻬﺎ
like C++, C#, or Java. We also need to learn how to .ﺑﻧﻔﺳﻙ
analyze and design programs.
The main aim of studying data structures is to develop ﺇﻥ ﺍﻟﻬﺩﻑ ﺍﻷﺳﺎﺳﻲ ﻣﻥ ﺩﺭﺍﺳﺔ ﻫﻳﺎﻛﻝ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻫﻭ ﺍﺳﺗﺧﺩﺍﻣﻬﺎ
efficient software applications. There are several steps ﻓﻲ ﺗﻁﻭﻳﺭ ﺍﻟﺑﺭﻣﺟﻳﺎﺕ ﺃﻱ ﺑﺭﻣﺟﺔ ﺍﻟﺗﻁﺑﻳﻘﺎﺕ ﻭﺍﻷﻧﻅﻣﺔ
that we need to learn, to develop functional applications, ﻭﻟﺻﻧﻊ ﻫﺫﻩ ﺍﻟﺗﻁﺑﻳﻘﺎﺕ ﻫﻧﺎﻟﻙ ﻋﺩﺩ ﻣﻥ ﺍﻟﺧﻁﻭﺍﺕ.ﺍﻟﺣﺎﺳﻭﺑﻳﺔ
which are free of errors. These steps are called the
ﺍﻟﺗﻲ ﻳﺟﺏ ﺍﺗﺑﺎﻋﻬﺎ ﻟﻠﻭﺻﻭﻝ ﺇﻟﻰ ﺗﻁﺑﻳﻘﺎﺕ ﻧﺎﺟﺣﺔ ﻭﺧﺎﻟﻳﺔ ﻣﻥ
problem-solving steps, and as follows:
: ﻭﻫﺫﻩ ﺍﻟﺧﻁﻭﺍﺕ ﻫﻲ ﻛﺎﻟﺗﺎﻟﻲ،ﺍﻷﺧﻁﺎء
1. Study and understand the problem: This is the most ﻭﻫﺫﻩ: ﺩﺭﺍﺳﺔ ﻭﻓﻬﻡ ﺍﻟﺗﻁﺑﻳﻖ )ﺍﻟﻧﻅﺎﻡ( ﺍﻟﻣﺭﺍﺩ ﺑﺭﻣﺟﺗﻪ.1
critical step. We need to understand what is ﺍﻟﺧﻁﻭﺓ ﻣﻥ ﺃﻫﻡ ﺍﻟﺧﻁﻭﺍﺕ ﺣﻳﺙ ﻳﺗﻡ ﺗﺣﺩﻳﺩ ﻣﺗﻁﻠﺑﺎﺕ
required from our application, and what exactly it ﻭﻋﺎﺩﺓ ﻳﻘﻭﻡ.ﻭﺃﻫﺩﺍﻑ ﺍﻟﻧﻅﺎﻡ ﺍﻟﻣﺣﻭﺳﺏ ﺑﺷﻛﻝ ﺩﻗﻳﻖ ﺟﺩﺍ
should do. In large software production companies, ﺍﻟﻣﺑﺭﻣﺞ ﺃﻭ ﻣﺣﻠﻝ ﺍﻟﻧﻅﻡ ﺑﺟﻣﻊ ﻛﻝ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ
persons called Systems Analysts collect all the ﺍﻟﻧﻅﺎﻡ ﺍﻟﻣﺭﺍﺩ ﺣﻭﺳﺑﺗﻪ ﻭﻋﻣﻝ ﺍﻻﺳﺗﺑﻳﺎﻧﺎﺕ ﻭﺍﻟﻣﻘﺎﺑﻼﺕ
6
M.A. Eljinini
information about the application to be ﻣﻊ ﺍﻷﺷﺧﺎﺹ ﺍﻟﻣﺳﺗﺧﺩﻣﻳﻥ ﻟﻠﻧﻅﺎﻡ ﺍﻟﻳﺩﻭﻱ ﺍﻟﺣﺎﻟﻲ ﻣﻥ
programmed. They usually conduct surveys and .ﻣﺩﺭﺍء ﻭﻣﻭﻅﻔﻳﻥ ﻭﻏﻳﺭﻫﻡ
conduct meetings with employees, managers, and ﻓﻲ ﻫﺫﻩ ﺍﻟﻣﺭﺣﻠﺔ ﻳﻘﻭﻡ ﺍﻟﻣﺣﻠﻝ:ﺗﺣﻠﻳﻝ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺣﺎﻟﻲ .2
users to understand their requirements. ﺑﺗﺣﻠﻳﻝ ﻛﻝ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﺍﻟﺗﻲ ﺣﺻﻝ ﻋﻠﻳﻬﺎ ﻭﻋﺎﺩﺓ ﻳﻘﻭﻡ
2. Analyze the problem (or the current manual ﺑﻌﻣﻝ ﺭﺳﻭﻣﺎﺕ ﺗﺑﻳﻥ ﻛﻳﻔﻳﺔ ﺍﻧﺳﻳﺎﺏ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻓﻲ
system): System analysts analyze all the collected ﻭﻣﻥ ﺃﺷﻬﺭ ﻫﺫﻩ ﺍﻟﺭﺳﻭﻣﺎﺕ ﺃﻭ،ﺍﻟﻧﻅﺎﻡ ﺍﻟﺣﺎﻟﻲ
data. They draw diagrams showing the flow of data ﻧﻅﺎﻡ ﻣﺑﻳﻌﺎﺕ ﺣﻳﺙ ﻳﻘﻭﻡ: ﻭﻣﺛﺎﻝ ﻋﻠﻰ ﺫﻟﻙ،ﺍﻟﻣﺧﻁﻁﺎﺕ
ﺍﻟﻣﻭﻅﻑ ﺑﺗﻌﺑﺋﺔ ﻧﻣﻭﺫﺝ ﻳﺣﺗﻭﻱ ﻋﻠﻰ ﻁﻠﺑﻳﻪ ﻣﻌﻳﻧﺔ
in the current system. These diagrams are called
ﻭﺗﺭﺳﻝ ﻧﺳﺧﺔ ﻣﻥ ﻫﺫﺍ ﺍﻟﻧﻣﻭﺫﺝ ﺇﻟﻰ ﺍﻟﻣﺣﺎﺳﺏ ﻛﻲ ﻳﻘﻭﻡ
Data Flow Diagrams (DFD). For example, in the
ﻛﻣﺎ ﺗﺭﺳﻝ ﻧﺳﺧﺔ ﺇﻟﻰ،ﺑﺈﻋﺩﺍﺩ ﻓﺎﺗﻭﺭﺓ ﻟﻠﻣﺷﺗﺭﻱ
purchasing system, the employee fills a purchasing
ﻭﺃﺧﺭﻯ ﻟﻺﺩﺍﺭﺓ ﻟﻣﺗﺎﺑﻌﺔ،ﺍﻟﻣﺳﺗﻭﺩﻉ ﻟﺗﺣﺿﻳﺭ ﺍﻟﻁﻠﺑﻳﺔ
order and sends a copy to the accounting ﺇﺫﺍ ﻣﻥ ﻣﻧﻅﻭﺭ ﺍﻟﻣﺣﻠﻝ ﻓﺈﻥ ﻫﺫﻩ ﻋﺑﺎﺭﺓ ﻋﻥ.ﺍﻟﻣﺑﻳﻌﺎﺕ
department to prepare the invoice. Another copy ﺑﻳﺎﻧﺎﺕ ﺗﻧﺗﻘﻝ ﻋﺑﺭ ﺍﻷﻗﺳﺎﻡ ﺍﻟﻣﺧﺗﻠﻔﺔ ﻓﻲ ﺍﻟﺷﺭﻛﺔ ﻭﻣﻥ
goes to the warehouse to prepare the items for .ﺍﻟﻣﻬﻡ ﺟﺩﺍ ﻣﺗﺎﺑﻌﺗﻬﺎ ﻛﻭﻧﻬﺎ ﺟﺯء ﻣﻥ ﺍﻟﻧﻅﺎﻡ ﺍﻟﻣﺣﻭﺳﺏ
shipping. Another copy goes to the manager so he ﻓﻲ ﻫﺫﻩ ﺍﻟﻣﺭﺣﻠﺔ ﻳﻘﻭﻡ ﺍﻟﻣﺣﻠﻝ:ﺗﺻﻣﻳﻡ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺟﺩﻳﺩ .3
can follow up. From the perspective of the system ﺑﺗﺻﻣﻳﻡ ﺷﺎﺷﺎﺕ ﺍﻟﻧﻅﺎﻡ ﻟﻛﻝ ﻋﻣﻠﻳﺔ ﻭﺃﻳﺿﺎ ﻗﻭﺍﻋﺩ
analyst, all these tasks are about data that flow ﺍﻟﺑﻳﺎﻧﺎﺕ ﺑﻣﺎ ﻓﻳﻬﺎ ﻣﻥ ﺟﺩﺍﻭﻝ ﻭﺍﻟﻌﻼﻗﺎﺕ ﺑﻳﻥ ﻫﺫﻩ
throughout the different departments of the ﻭﺃﻳﺿﺎ ﺗﺻﻣﻳﻡ ﺍﻟﺗﻘﺎﺭﻳﺭ ﻭﻏﻳﺭﻫﺎ ﻭﺍﻟﺗﻲ ﺗﻣﺛﻝ،ﺍﻟﺟﺩﺍﻭﻝ
company. ﺑﺎﻹﺿﺎﻓﺔ،ﺍﻷﺟﺯﺍء ﺍﻟﺭﺋﻳﺳﻳﺔ ﻟﻠﻧﻅﺎﻡ ﺍﻟﻣﺣﻭﺳﺏ ﺍﻟﺟﺩﻳﺩ
3. System Design: This step is about the design of the .ﺇﻟﻰ ﺍﻟﺧﻭﺍﺭﺯﻣﻳﺎﺕ ﻟﻛﻝ ﻋﻣﻠﻳﺔ ﻳﻘﻭﻡ ﺑﻬﺎ ﺍﻟﻧﻅﺎﻡ
new application. There are many tasks to be ﻗﺩ ﻳﻘﻭﻡ ﻣﺑﺭﻣﺟﺎ ﻭﺍﺣﺩﺍ ﺑﺗﻧﻔﻳﺫ ﻫﺫﻩ:ﺑﺭﻣﺟﺔ ﺍﻟﻧﻅﺎﻡ .4
performed. For example, the design of data input ﺍﻟﺧﻁﻭﺓ ﻭﻓﻲ ﺍﻟﺷﺭﻛﺎﺕ ﺍﻟﻛﺑﻳﺭﺓ ﻗﺩ ﻳﻌﻬﺩ ﻟﻌﺩﺩ ﻣﻥ
screens, reports, and databases. The design of .ﺍﻟﻣﺑﺭﻣﺟﻳﻥ ﺇﻟﻰ ﺑﺭﻣﺟﺔ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺟﺩﻳﺩ ﺑﺄﻗﺳﺎﻣﻪ ﺍﻟﻣﺧﺗﻠﻔﺔ
ﻭﻋﺎﺩﺓ ﻳﻘﻭﻡ ﺍﻟﻣﺣﻠﻝ ﺑﺗﺣﺩﻳﺩ ﻟﻐﺔ ﺍﻟﺑﺭﻣﺟﺔ ﺍﻷﻧﺳﺏ ﻹﺗﻣﺎﻡ
algorithms, which are the logic of the tasks that the
ﻭﺣﺎﻟﻳﺎ ﻫﻧﺎﻟﻙ ﺍﻟﻣﺋﺎﺕ ﻣﻥ ﻟﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ.ﻫﺫﻩ ﺍﻟﻣﻬﻣﺔ
application needs to perform, like calculations and
ﺑﻌﺿﻬﺎ ﻋﺎﻡ ﺍﻻﺳﺗﺧﺩﺍﻡ ﻭﺑﻌﺿﻬﺎ ﻣﺗﺧﺻﺹ ﻷﻧﻅﻣﺔ
processing of data.
ﻭﺟﻣﻳﻌﺎ ﺗﺷﺗﺭﻙ ﻓﻲ ﻧﻔﺱ ﺍﻟﻬﺩﻑ ﻭﻫﻭ ﺇﻧﺗﺎﺝ.ﻣﻌﻳﻧﺔ
4. System implementation: In this step, a suitable .ﺑﺭﻣﺟﻳﺎﺕ ﺗﻁﺑﻳﻘﻳﺔ
programming language is used to code the ﻳﻘﻭﻡ ﺍﻟﻣﺑﺭﻣﺞ ﺃﻭ ﺷﺧﺹ ﻣﻌﻳﻥ:ﺍﺧﺗﺑﺎﺭ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺟﺩﻳﺩ .5
programs and turn them into useful applications. ﻛﺄﻥ ﻳﻘﻭﻡ،ﻓﻲ ﺍﺧﺗﺑﺎﺭ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺟﺩﻳﺩ ﺑﺷﻛﻝ ﻛﺎﻣﻝ ﻭﺷﺎﻣﻝ
5. Testing the new system: In large companies, a ﺑﺗﺟﺭﺑﺔ ﺟﻣﻳﻊ ﺍﻻﺣﺗﻣﺎﻻﺕ ﻭﺗﺩﻭﻳﻥ ﻣﺎ ﻳﺣﺩﺙ ﻓﻲ ﻛﻝ
person who is called system tester performs all ﻭﺍﻟﻬﺩﻑ ﻫﻭ ﺇﻳﺟﺎﺩ ﺍﻷﺧﻁﺎء.ﺍﺣﺗﻣﺎﻝ ﻳﻘﻭﻡ ﺑﺎﺧﺗﺑﺎﺭﻩ
types of tests on the new system. For example, he ﻭﺗﺻﺣﻳﺣﻬﺎ ﻗﺑﻝ ﺧﺭﻭﺝ ﺍﻟﺑﺭﻧﺎﻣﺞ ﺇﻟﻰ ﺍﻟﻭﺍﻗﻊ
may enter all types of data taking all the probabilities .ﻭﺍﺳﺗﺧﺩﺍﻣﻪ
that users may enter. In every step, he writes down ﻳﻘﻭﻡ ﺍﻟﻣﺣﻠﻝ ﺑﺗﻭﺛﻳﻖ ﺍﻟﻌﻣﻠﻳﺔ ﺑﺄﻛﻣﻠﻬﺎ ﺑﺎﻹﺿﺎﻓﺔ:ﺍﻟﺗﻭﺛﻳﻖ .6
the results aiming to find and report errors. ﺇﻟﻰ ﺗﻭﺛﻳﻖ ﻁﺭﻳﻘﺔ ﺍﺳﺗﺧﺩﺍﻡ ﺍﻟﺑﺭﻧﺎﻣﺞ ﻻﺳﺗﺧﺩﺍﻣﻪ ﻣﻥ ﻗﺑﻝ
6. Documentation: Besides documenting the whole ﺍﻟﻣﺳﺗﺧﺩﻡ )ﺩﻟﻳﻝ ﺍﻟﻣﺳﺗﺧﺩﻡ( ﻭﺃﻳﺿﺎ ﺇﻟﻰ ﻛﻳﻔﻳﺔ ﺗﻧﺻﻳﺏ
process, programmers usually produce a book .ﺍﻟﺑﺭﻧﺎﻣﺞ ﻭﻣﺗﻁﻠﺑﺎﺗﻪ ﻣﻥ ﻣﻌﺩﺍﺕ ﻭﺑﺭﻣﺟﻳﺎﺕ ﻭﻏﻳﺭﻫﺎ
(User Guide), which shows how to set up and use
the new system in detail.
In this part, we present a case study on how to ﻛﻣﺎ ﺗﻡ ﺫﻛﺭﻩ ﺳﺎﺑﻘﺎ ﻓﺈﻥ ﻫﺫﺍ ﺍﻟﺟﺯء ﻳﻬﺩﻑ ﺇﻟﻰ ﻋﺭﺽ ﻛﻳﻔﻳﺔ ﺗﻁﻭﻳﺭ
develop an application for the library. Before we ﻭﻗﺑﻝ ﺍﻟﺑﺩء ﻓﻲ ﻛﺗﺎﺑﺔ ﺍﻟﻛﻭﺩ ﺑﻠﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ ﻻ ﺑﺩ ﻟﻧﺎ،ﺍﻟﺑﺭﺍﻣﺞ ﻭﺇﻋﺩﺍﺩﻫﺎ
start coding the application, we need to start .ﺍﻥ ﻧﺳﺗﻌﺭﺽ ﻛﻝ ﺧﻁﻭﺓ ﺑﺎﻟﺗﻔﺻﻳﻝ ﻛﻲ ﻧﺗﻣﻛﻥ ﻣﻥ ﻛﺗﺎﺑﺔ ﺑﺭﺍﻣﺞ ﻣﻔﻳﺩﺓ
from the beginning. Let us assume the library ﻭﺳﻧﻘﻭﻡ ﺑﺫﻟﻙ ﻣﻥ ﺧﻼﻝ ﺷﺭﺡ ﻣﺛﺎﻻً ﻭﺍﻗﻌﻳﺎ ﻭﺍﻟﺫﻱ ﺳﻧﺳﺗﺧﺩﻣﻪ ﻓﻲ ﺷﺭﺡ
manager asked us to design a computer ﻓﻣﺛﻼ ﻟﻭ ﻓﺭﺿﻧﺎ ﺃﻥ ﺃﺣﺩ.ﻣﻔﺎﻫﻳﻡ ﻫﻳﺎﻛﻝ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺍﻟﻔﺻﻭﻝ ﺍﻟﻘﺎﺩﻣﺔ
7
Practical Data Structures with C++, C#, and Java
application to help her in the operations of ﺍﻷﺷﺧﺎﺹ ﻳﻌﻣﻝ ﻣﺩﻳﺭﺍ ﻓﻲ ﺍﻟﻣﻛﺗﺑﺔ ﻗﺩ ﻁﻠﺏ ﻣﻧﺎ ﺃﻥ ﻧﺻﻣﻡ ﻟﻪ ﺑﺭﻧﺎﻣﺟﺎ
borrowing books. We need to understand all the ﺃﻱ ﺃﻥ.ﻟﻣﺳﺎﻋﺩﺗﻪ ﻓﻲ ﻋﻣﻠﻳﺔ ﺇﻋﺎﺭﺓ ﺍﻟﻛﺗﺏ ﺍﻟﻣﻭﺟﻭﺩﺓ ﻓﻲ ﺍﻟﻣﻛﺗﺑﺔ
details first. .ﺍﻟﻣﻁﻠﻭﺏ ﺑﺭﻣﺟﺔ ﻧﻅﺎﻡ ﺇﻋﺎﺭﺓ ﻛﺗﺏ ﻓﻲ ﻣﻛﺗﺑﺔ ﺍﻟﺟﺎﻣﻌﺔ ﻋﻠﻰ ﺳﺑﻳﻝ ﺍﻟﻣﺛﺎﻝ
.ﻭﻫﻧﺎ ﻻ ﺑﺩ ﻣﻥ ﺩﺭﺍﺳﺔ ﻭﻓﻬﻡ ﻣﺗﻁﻠﺑﺎﺕ ﺍﻟﻧﻅﺎﻡ ﺑﻛﻝ ﺗﻔﺻﻳﻼﺗﻪ ﺃﻭﻻ
8
M.A. Eljinini
4. The employee then returns the book to the bookshelf .4ﺃﻳﺿﺎ ﺗﻘﻭﻡ ﺑﺗﺩﻭﻳﻥ ﺍﻟﺗﺎﺭﻳﺦ ﻓﻲ ﺍﻟﺟﺩﻭﻝ ﻭﺍﻟﻣﻭﺟﻭﺩ ﻓﻲ
where it belongs. ﺁﺧﺭ ﺻﻔﺣﺔ ،ﻭﺗﻌﻳﺩ ﺍﻟﻛﺗﺎﺏ ﺇﻟﻰ ﻣﻛﺎﻧﻪ ﺍﻟﻣﺧﺻﺹ ﻋﻠﻰ
After that, we asked the employee about other ﺍﻟﺭﻑ ﻹﻋﺎﺭﺗﻪ ﻣﻥ ﺟﺩﻳﺩ.
operations and problems that she faces during her
ﺑﻌﺩ ﺫﻟﻙ ﺳﺄﻟﻧﺎ ﺍﻟﻣﻭﻅﻔﺔ ﺇﻥ ﻛﺎﻧﺕ ﻫﻧﺎﻟﻙ ﺇﺟﺭﺍءﺍﺕ ﺃﺧﺭﻯ ﺗﻘﻭﻡ
work. She mentioned that students after graduation ﺑﻬﺎ ﻓﻲ ﻋﻣﻠﻬﺎ ،ﻭﺃﻳﺿﺎ ﻋﻥ ﺍﻟﺻﻌﺎﺏ ﻭﺍﻟﻣﺷﺎﻛﻝ ﺍﻟﺗﻲ ﺗﻭﺍﺟﻬﻬﺎ.
comes back to the library to sign a quittance form. In ﻓﺫﻛﺭﺕ ﻟﻧﺎ ﺃﻥ ﺍﻟﻁﺎﻟﺏ ﻓﻲ ﻣﺭﺣﻠﺔ ﺍﻟﺗﺧﺭﺝ ﻳﻁﻠﺏ ﺑﺭﺍءﺓ ﺫﻣﺗﻪ
this case, the employee must search all cards in the ﻣﻥ ﺍﻟﻣﻛﺗﺑﺔ ،ﻭﻫﻧﺎ ﻻ ﺑﺩ ﻣﻥ ﺇﺟﺭﺍء ﻋﻣﻠﻳﺔ ﺑﺣﺙ ﻟﻠﺗﺄﻛﺩ ﻣﻥ ﺃﻥ
drawer to ensure that the student has returned all ﺍﻟﻁﺎﻟﺏ ﻗﺎﻡ ﺑﺈﻋﺎﺩﺓ ﺟﻣﻳﻊ ﺍﻟﻛﺗﺏ ﺍﻟﺗﻲ ﺍﺳﺗﻌﺎﺭﻫﺎ .ﻭﻗﺩ ﻳﻁﻠﺏ
borrowed books. Another problem is that the manager ﻣﺩﻳﺭ ﺍﻟﻣﻛﺗﺑﺔ ﻣﻥ ﺍﻟﻣﻭﻅﻔﺔ ﺇﻋﺩﺍﺩ ﺗﻘﺭﻳﺭ ﺑﺎﻟﻛﺗﺏ ﺍﻟﻣﺗﺄﺧﺭﺓ
may ask her to prepare a report showing all the late ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ ﺗﻘﺎﺭﻳﺭ ﺃﺧﺭﻯ ﻭﺍﻟﺗﻲ ﺗﻌﺗﺑﺭ ﻣﻥ ﺍﻟﻌﻣﻠﻳﺎﺕ
ﺍﻟﻣﺿﻧﻳﺔ ﻳﺩﻭﻳﺎ ﻭﺍﻟﻣﻌﺭﺿﺔ ﻟﻸﺧﻁﺎء ﺍﻟﺑﺷﺭﻳﺔ .ﻣﻥ ﻫﻧﺎ ﻧﺭﻯ
books. All these operations are subject to human errors. ﺃﻫﻣﻳﺔ ﺣﻭﺳﺑﺔ ﻫﺫﻩ ﺍﻷﻧﻅﻣﺔ ﻭﺍﻟﺗﻲ ﺗﺳﺎﻋﺩ ﻓﻲ ﺍﻟﻘﺿﺎء ﻋﻠﻰ
Some of these operations require hard work and may ﺍﻷﺧﻁﺎء ﺍﻟﺑﺷﺭﻳﺔ ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ ﺗﻘﻠﻳﻝ ﺍﻟﻭﻗﺕ ﻭﺍﻟﺟﻬﺩ ﻓﻲ
take a long time to achieve. Paper forms may be ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﻣﻁﻠﻭﺑﺔ ﺑﺷﻛﻝ ﻛﺑﻳﺭ ﻭﻓﺎﻋﻝ .ﺇﻥ ﻫﺫﻩ ﺍﻷﻧﻅﻣﺔ
misplaced or lost. Computer applications help us ﺍﻟﺣﺎﺳﻭﺑﻳﺔ ﺗﻌﻣﻝ ﻋﻠﻰ ﻣﻌﺎﻟﺟﺔ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻣﻥ ﺗﺧﺯﻳﻧﻬﺎ
bypass all these problems. They can accomplish tasks ﻭﺍﺳﺗﻌﺎﺩﺗﻬﺎ ﻭﻋﺭﺿﻬﺎ ﺑﺷﻛﻝ ﺃﻭ ﺑﺂﺧﺭ ﻭﺑﺷﻛﻝ ﺳﺭﻳﻊ ﻭﺩﻗﻳﻖ
easy and super-fast. ﺟﺩﺍ.
Computers are mostly about processing data ﻳﻣﻛﻥ ﺍﻻﺳﺗﻧﺗﺎﺝ ﻣﻣﺎ ﺳﺑﻖ ﺃﻥ ﻫﻧﺎﻟﻙ ﺧﻁﻭﺍﺕ ﻣﻌﻳﻧﻪ ﻗﺎﻣﺕ ﺑﻬﺎ
and turning it into useful information. From ﺍﻟﻣﻭﻅﻔﺔ ﻋﻧﺩ ﺇﻋﺎﺭﺓ ﺍﻟﻛﺗﺎﺏ ﻭﺍﺳﺗﺭﺟﺎﻋﻪ ،ﻭﺃﻳﺿﺎ ﻫﻧﺎﻟﻙ ﻣﻌﻠﻭﻣﺎﺕ
observing the above operations, we have ﻣﻌﻳﻧﻪ ﺗﻡ ﺗﺩﺍﻭﻟﻬﺎ ﻭﺗﺩﻭﻳﻧﻬﺎ ﺧﻼﻝ ﺍﻟﻌﻣﻠﻳﺗﻳﻥ ،ﻭﻫﺫﻩ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻫﻲ:
noticed that there is some information that has
been written down and kept, such as: -ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺍﻟﻁﺎﻟﺏ )ﺍﺳﻡ ﺍﻟﻁﺎﻟﺏ ﻭﺭﻗﻣﻪ ﺍﻟﺟﺎﻣﻌﻲ(
- Information about the student (Student name -ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺍﻟﻛﺗﺎﺏ )ﻋﻧﻭﺍﻥ ﺍﻟﻛﺗﺎﺏ ﻭﺭﻗﻣﻪ(
)and number -ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺣﺩﺙ ﺍﻹﻋﺎﺭﺓ )ﺍﻟﻁﺎﻟﺏ ﺍﻟﻣﺳﺗﻌﻳﺭ ،ﺍﻟﻛﺗﺎﺏ ﺍﻟﻣﻌﺎﺭ،
ﻭﺗﺎﺭﻳﺦ ﺍﻹﻋﺎﺭﺓ(
- Information about the book (Book type and
-ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺣﺩﺙ ﺍﻹﻋﺎﺩﺓ )ﺍﺳﻡ ﺍﻟﻁﺎﻟﺏ ﺍﻟﺫﻱ ﺃﻋﺎﺩ ﺍﻟﻛﺗﺎﺏ،
)number
ﻋﻧﻭﺍﻥ ﺍﻟﻛﺗﺎﺏ ﺍﻟﺗﻲ ﺗﻣﺕ ﺇﻋﺎﺩﺗﻪ ،ﻭﺗﺎﺭﻳﺦ ﺇﻋﺎﺩﺓ ﺍﻟﻛﺗﺎﺏ(
- Information about the borrowing task
)(Student, Book, Borrowing Date ﺃﻣﺎ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﺍﻟﻣﻁﻠﻭﺑﺔ ﻋﻧﺩ ﻋﻣﻠﻳﺔ ﺍﻟﺑﺣﺙ ﻓﻬﻲ:
- Information about the returning task
)(Student, Book, Returning Date -ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺍﻟﻛﺗﺏ ﺍﻟﻣﻌﺎﺭﺓ ﻟﻁﺎﻟﺏ ﻣﻌﻳﻥ
-ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﺍﻟﻛﺗﺏ ﺍﻟﻣﺗﺄﺧﺭﺓ
Information needed when performing a search: -ﻣﻌﻠﻭﻣﺎﺕ ﻋﻥ ﻛﺗﺎﺏ ﻣﻌﻳﻥ ﻟﻣﻌﺭﻓﺔ ﺇﻥ ﻛﺎﻥ ﺍﻟﻛﺗﺎﺏ ﻣﻌﺎﺭ ﺃﻡ ﻏﻳﺭ
ﻣﻌﺎﺭ
- Information about the borrowed book
-ﻣﻌﻠﻭﻣﺎﺕ ﺃﺧﺭﻯ ﻗﺩ ﻳﺣﺗﺎﺝ ﺇﻟﻳﻬﺎ ﺍﻟﻣﺩﻳﺭ ﻣﻥ ﺗﻘﺎﺭﻳﺭ ﻭﻏﻳﺭﻫﺎ
- Information about late books
- Information about the status of a specific ﺇﺫﺍ ﻫﻧﺎﻟﻙ ﺃﺭﺑﻊ ﻋﻣﻠﻳﺎﺕ ﺭﺋﻳﺳﻳﺔ ﺗﻘﻭﻡ ﺑﻬﺎ ﺍﻟﻣﻭﻅﻔﺔ ﻭﻫﻲ:
book
- Other reports for management. ﺇﻋﺎﺭﺓ ﻛﺗﺎﺏ .1
ﺇﻋﺎﺩﺓ ﻛﺗﺎﺏ .2
There are four main tasks that the employee ﻋﻣﻠﻳﺎﺕ ﺍﻟﺑﺣﺙ .3
does: ﺇﻋﺩﺍﺩ ﺍﻟﺗﻘﺎﺭﻳﺭ )ﻣﺛﻼ :ﻁﺑﺎﻋﺔ ﻗﺎﺋﻣﺔ ﺑﺄﺳﻣﺎء ﺍﻟﻛﺗﺏ ﺍﻟﻣﻌﺎﺭﺓ( .4
1. Borrowing Book ﻭﺍﻵﻥ ﻧﺣﺗﺎﺝ ﻓﻲ ﻫﺫﻩ ﺍﻟﻣﺭﺣﻠﺔ ﺇﻟﻰ ﺇﻋﺩﺍﺩ ﺭﺳﻭﻣﺎﺕ ﺗﺑﻳﻥ ﺍﻧﺳﻳﺎﺏ
2. Returning Book ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺣﺎﻟﻲ ﻭﺗﺳﺎﻋﺩ ﺍﻟﻣﺑﺭﻣﺞ ﻓﻲ ﺗﺻﻣﻳﻡ ﺍﻟﻧﻅﺎﻡ
3. Searching for Books ﺍﻟﺟﺩﻳﺩ .ﺇﻥ ﺍﻟﺷﻛﻝ 4-1ﻳﺑﻳﻥ ﻋﻣﻠﻳﺎﺕ ﺇﻋﺎﺭﺓ ﻛﺗﺎﺏ ﻭﻛﻣﺎ ﺷﺭﺣﺗﻬﺎ
4. Producing Reports (i.e., printing lists of ﺍﻟﻣﻭﻅﻔﺔ ،ﻓﺎﻟﺩﻭﺍﺋﺭ ﺗﺑﻳﻥ ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﺗﻲ ﻗﺎﻣﺕ ﺑﻬﺎ ﻭﺍﻟﻣﺳﺗﻁﻳﻼﺕ
ﺗﺑﻳﻥ ﻣﺩﺧﻼﺕ ﻭﻣﺧﺭﺟﺎﺕ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻭﺍﻷﺳﻬﻡ ﺍﻟﺭﻓﻳﻌﺔ ﺗﺑﻳﻥ ﺍﻧﺳﻳﺎﺏ
9
Practical Data Structures with C++, C#, and Java
At this stage, we need to prepare some drawings ﻋﻣﻠﻳﺎﺕ ﺇﻋﺎﺩﺓ ﻛﺗﺎﺏ ﻭﺃﻳﺿﺎ ﻛﻣﺎ ﺷﺭﺣﺗﻬﺎ5-1 ﻛﻣﺎ ﻳﺑﻳﻥ ﺍﻟﺷﻛﻝ
that show data flows in the current system. Such .ﺍﻟﻣﻭﻅﻔﺔ
diagrams are called Data Flow Diagrams (DFD),
which provide great help to programmers when .ﻭﺳﻧﺗﺭﻙ ﺍﻟﺭﺳﻭﻡ ﺍﻟﺗﻲ ﺗﺑﻳﻥ ﻋﻣﻠﻳﺎﺕ ﺍﻟﺑﺣﺙ ﻛﺗﻣﺭﻳﻥ ﻟﻠﻁﺎﻟﺏ
designing the new system. Figure 1-4 shows
the tasks of borrowing books, which we
explained in the previous section. Circles show
tasks, and rectangles are for input and output
operations, while arrows show the flow of data.
10
M.A. Eljinini
At this stage, we shall design the input screens for the new ﻓﻲ ﻫﺫﻩ ﺍﻟﻣﺭﺣﻠﺔ ﻳﻘﻭﻡ ﺍﻟﻣﺑﺭﻣﺞ ﺑﺗﺻﻣﻳﻡ ﺷﺎﺷﺎﺕ ﺍﻟﻧﻅﺎﻡ
system. These screens must automate reality! We need ﺑﺎﻹﺿﺎﻓﺔ ﺇﻟﻰ ﺗﺻﻣﻳﻡ ﺍﻟﻣﻠﻔﺎﺕ،ﻭﺍﻟﺗﻲ ﺗﺣﺎﻛﻲ ﺍﻟﻭﺍﻗﻊ
to design reports, output screens, and the data storage of ﺍﻟﺗﻲ ﻳﺣﺗﺎﺟﻬﺎ ﺍﻟﻧﻅﺎﻡ ﻟﺗﺧﺯﻳﻥ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻭﺃﻳﺿﺎ ﺗﺻﻣﻳﻡ
files for storing data. Another important task that we need ﻭﻣﻥ ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻟﻣﻬﻣﺔ ﻓﻲ ﻫﺫﻩ.ﺍﻟﺗﻘﺎﺭﻳﺭ ﺍﻟﻣﻁﻠﻭﺑﺔ
to consider is designing the algorithm for each task, such ﺍﻟﻣﺭﺣﻠﺔ ﺗﺻﻣﻳﻡ ﺍﻟﺧﻭﺍﺭﺯﻣﻳﺎﺕ ﻟﻣﻌﺎﻟﺟﺔ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ
as borrowing books and returning books. Usually, ﻣﺭﺍﺣﻠﻬﺎ ﺍﻟﻣﺧﺗﻠﻔﺔ ﻣﻥ ﻋﻣﻠﻳﺎﺕ ﺍﻟﺑﺣﺙ ﻭﺍﻟﻌﻣﻠﻳﺎﺕ
programmers use diagrams to help them with the design of ﻭﻋﺎﺩﺓ،ﺍﻟﺣﺳﺎﺑﻳﺔ ﺇﻥ ﻭﺟﺩﺕ ﻭﻏﻳﺭﻫﺎ ﻣﻥ ﺍﻟﻌﻣﻠﻳﺎﺕ
algorithms. Now, we shall present the main algorithm, as ﻳﺳﺗﻌﻳﻥ ﺑﺎﻟﺭﺳﻭﻣﺎﺕ ﺍﻟﺗﻲ ﻋﺭﺿﻧﺎﻫﺎ ﻓﻲ ﺍﻟﺟﺯء ﺍﻟﺳﺎﺑﻖ
follows: ﻭﻫﻧﺎ.ﻭﺍﻟﺗﻲ ﺗﺑﻳﻥ ﺍﻧﺳﻳﺎﺏ ﺍﻟﺑﻳﺎﻧﺎﺕ ﻓﻲ ﺍﻟﻧﻅﺎﻡ ﺍﻟﻳﺩﻭﻱ
ﺳﻭﻑ ﻧﻌﺭﺽ ﺍﻟﺧﻭﺍﺭﺯﻣﻳﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ ﻭﺍﻟﺗﻲ ﺗﻌﻣﻝ ﻋﻧﺩ
:ﺗﺷﻐﻳﻝ ﺍﻟﻧﻅﺎﻡ ﺍﻟﺟﺩﻳﺩ ﻭﺗﻛﻭﻥ ﻛﺎﻟﺗﺎﻟﻲ
1. Display the main menu on the screen, which contains
three options (borrow a book, return the book, and ﺇﻅﻬﺎﺭ ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ ﻭﺍﻟﺗﻲ ﺗﺣﺗﻭﻱ ﻋﻠﻰ .1
search for the book), in addition to a fourth option, ، ﺇﻋﺎﺩﺓ ﻛﺗﺎﺏ،ﺍﻟﺧﻳﺎﺭﺍﺕ ﺍﻟﺛﻼﺙ )ﺍﻋﺎﺭﺓ ﻛﺗﺎﺏ
which is to exit from the system. When we code our ﻭﺍﻟﺑﺣﺙ( ﺑﺎﻹﺿﺎﻓﺔ ﻟﺧﻳﺎﺭ ﺭﺍﺑﻊ ﻭﻫﻭ ﺍﻟﺧﺭﻭﺝ
program, we place the commands to display the main ﺑﺭﻣﺟﻳﺎ ﺗﻭﺿﻊ ﺃﻭﺍﻣﺭ ﺇﻅﻬﺎﺭ ﺍﻟﻘﺎﺋﻣﺔ.ﻣﻥ ﺍﻟﻧﻅﺎﻡ
menu inside a method (method MainMenu), which is ( ﻭﺍﻟﺗﻲ ﻳﺗﻡMainMenu) ﺍﻟﺭﺋﻳﺳﻳﺔ ﺑﺩﺍﻟﺔ
called whenever the system needs to show the main .ﺍﺳﺗﺩﻋﺎﺋﻬﺎ ﻛﻠﻣﺎ ﺍﺣﺗﺎﺝ ﺍﻟﻧﻅﺎﻡ ﺇﻟﻰ ﺇﻅﻬﺎﺭﻫﺎ
menu. ﺍﻟﻁﻠﺏ ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ )ﺍﻟﻣﻭﻅﻑ( ﺍﺧﺗﻳﺎﺭ ﺇﺣﺩﻯ .2
2. The user (employee) chooses one of these four ﻭﺫﻟﻙ ﺣﺳﺏ ﺍﻟﻣﻁﻠﻭﺏ،ﻫﺫﻩ ﺍﻟﻌﻣﻠﻳﺎﺕ ﺍﻷﺭﺑﻌﺔ
options, according to the required task at that moment. .ﻣﻧﻪ ﻓﻲ ﺗﻠﻙ ﺍﻟﻠﺣﻅﺔ
3. In the case of choosing, borrow a book: Go to the ﺍﻻﻧﺗﻘﺎﻝ ﺇﻟﻰ ﻋﻣﻠﻳﺔ:ﻓﻲ ﺣﺎﻝ ﺍﺧﺗﻳﺎﺭ ﺍﻋﺎﺭﺓ ﻛﺗﺎﺏ .3
borrowing process by calling the borrowing method ﺍﻹﻋﺎﺭﺓ ﺩﺍﻟﺔ ﺑﺎﺳﺗﺩﻋﺎء ﺍﻹﻋﺎﺭﺓ
(Method BorrowBook). Return to the main menu after ﻭﺑﻌﺩ ﺍﻻﻧﺗﻬﺎء ﻣﻧﻬﺎ ﻳﺗﻡ،(BorrowBook)
.ﺍﻟﻌﻭﺩﺓ ﺇﻟﻰ ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ
completion of the borrowing task.
ﺍﻻﻧﺗﻘﺎﻝ ﺇﻟﻰ ﻋﻣﻠﻳﺔ:ﻓﻲ ﺣﺎﻝ ﺍﺧﺗﻳﺎﺭ ﺇﻋﺎﺩﺓ ﻛﺗﺎﺏ .4
4. In the case of choosing to return the book: Go to the
ﺩﺍﻟﺔ ﺑﺎﺳﺗﺩﻋﺎء ﻭﺫﻟﻙ ﺍﻹﻋﺎﺩﺓ
returning book process by calling the returning book
ﻭﺑﻌﺩ ﺍﻻﻧﺗﻬﺎء،(ReturnBook) ﺍﻹﻋﺎﺩﺓ
method (Method ReturnBook), Return to the main .ﻣﻧﻬﺎ ﻳﺗﻡ ﺍﻟﻌﻭﺩﺓ ﺇﻟﻰ ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ
menu after completion of the returning task. ﺍﻻﻧﺗﻘﺎﻝ ﺇﻟﻰ ﻋﻣﻠﻳﺎﺕ:ﻓﻲ ﺣﺎﻝ ﺍﺧﺗﻳﺎﺭ ﺍﻟﺑﺣﺙ .5
5. In the case of choosing to search for a book: Go to the ﺍﻟﺑﺣﺙ ﺍﻟﻣﻁﻠﻭﺑﺔ ﻭﺃﻳﺿﺎ ﻋﻥ ﻁﺭﻳﻖ ﺍﺳﺗﺩﻋﺎء
searching process by calling the searching method ﻭﺑﻌﺩ ﺍﻻﻧﺗﻬﺎء ﻣﻧﻬﺎ ﻳﺗﻡ،ﺍﻟﺩﺍﻟﺔ ﺍﻟﺧﺎﺻﺔ ﺑﻬﺎ
(Method SearchBook), Return to the main menu after .ﺍﻟﻌﻭﺩﺓ ﺇﻟﻰ ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ
completion of the searching task. ﺍﻻﻧﺗﻘﺎﻝ:ﻓﻲ ﺣﺎﻝ ﺍﺧﺗﻳﺎﺭ ﺍﻟﺧﺭﻭﺝ ﻣﻥ ﺍﻟﻧﻅﺎﻡ .6
6. If we choose to get out of the system, then we select ﺇﻟﻰ ﻋﻣﻠﻳﺎﺕ ﺍﻟﺧﺭﻭﺝ ﻣﻥ ﺍﻟﻧﻅﺎﻡ ﻭﻣﻥ ﺛﻡ
Exit. .ﺍﻟﺧﺭﻭﺝ ﻣﻥ ﺍﻟﻧﻅﺎﻡ
Figure 1-6 shows the main algorithm to the system as ﺍﻟﺗﺎﻟﻲ ﻳﺑﻳﻥ ﺍﻟﺧﻭﺍﺭﺯﻣﻳﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ6-1 ﺍﻟﺷﻛﻝ
explained above. . ﻭﻛﻣﺎ ﺗﻡ ﺷﺭﺣﻪ ﻓﻲ ﺍﻷﻋﻠﻰ،.ﻟﻠﻧﻅﺎﻡ
11
Practical Data Structures with C++, C#, and Java
Student Name:
Figure 1-7: The Main Menu
XXXXXXXXXXXX
When entering (1), the first choice in the menu, the program
calls the method for borrowing books, which in turn displays Book Title: XXXXXXXXXXXX
the “Borrow Book” screen, as shown in figure 1-8.
In figure 1-8, the system asks to enter the student ID ﻋﻧﺩ ﺇﺩﺧﺎﻝ ) (2ﺍﻟﺧﻳﺎﺭ ﺍﻟﺛﺎﻧﻲ ﻓﻲ ﺍﻟﻘﺎﺋﻣﺔ ﻭﻫﻭ ﺍﻋﺎﺩﺓ
number and Book number (in the red color). Then the ﺍﻟﻛﺗﺎﺏ ﻳﻧﻘﻠﻧﺎ ﺍﻟﻧﻅﺎﻡ ﺍﻟﻰ ﺍﻟﺷﻛﻝ .9-1
system searches for student name and the book title and
displays them below (in green color) and asks the user to ﻣﻥ ﻫﺫﺍ ﺍﻟﺷﻛﻝ ﻧﻼﺣﻅ ﺃﻥ ﺍﻟﻧﻅﺎﻡ ﻁﻠﺏ ﺇﺩﺧﺎﻝ ﺭﻗﻡ
confirm the information by entering (Y) for yes or (N) for no. ﺍﻟﻛﺗﺎﺏ ﻓﻘﻁ )ﺑﺎﻟﻠﻭﻥ ﺍﻷﺣﻣﺭ( ،ﺣﻳﺙ ﻳﻌﺭﺽ ﺍﺳﻡ
Once the task ends, the system goes back to the main ﺍﻟﻁﺎﻟﺏ ﻭﻋﻧﻭﺍﻥ ﺍﻟﻛﺗﺎﺏ )ﺑﺎﻟﻠﻭﻥ ﺍﻷﺧﺿﺭ( ﻭﻳﻁﻠﺏ
menu. ﻣﻥ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺍﻟﺗﺄﻛﺩ ﻣﻥ ﺍﻟﻣﻌﻠﻭﻣﺎﺕ ﻭﻓﻲ ﺣﺎﻝ ﺍﻟﺗﺄﻛﺩ
When the user enters the second choice, that is returning ﻳﻘﻭﻡ ﺍﻟﻣﺳﺗﺧﺩﻡ ﺑﺈﺩﺧﺎﻝ ﺍﻟﺣﺭﻑ ) (Yﻟﻳﻘﻭﻡ ﺍﻟﻧﻅﺎﻡ
book; the system displays the Return Book screen, as ﺑﺗﺄﻛﻳﺩ ﺇﻋﺎﺩﺓ ﺍﻟﻛﺗﺎﺏ ﻭﺇﻟﻐﺎء ﺍﻹﻋﺎﺭﺓ ،ﻛﺣﺫﻑ ﺭﻗﻡ
shown in figure 1-9. We should notice that the system ﺍﻟﻁﺎﻟﺏ ﻣﻥ ﺳﺟﻝ ﺍﻟﻛﺗﺎﺏ ﻣﺛﻼ .ﻭﻣﻥ ﺛﻡ ﻳﻌﻭﺩ ﺇﻟﻰ
asks the user for book numbers only (in red). The system ﺷﺎﺷﺔ ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ .ﺃﻣﺎ ﻓﻲ ﺣﺎﻟﺔ ﺃﺩﺧﻝ ﺍﻟﻣﺳﺗﺧﺩﻡ
displays the student name and the book title and asks for ﺍﻟﺣﺭﻑ ) (Nﻳﻘﻭﻡ ﺍﻟﻧﻅﺎﻡ ﺑﺈﻟﻐﺎء ﺍﻟﻌﻣﻠﻳﺔ ﻭﺍﻟﻌﻭﺩﺓ ﺇﻟﻰ
confirmation. Once the user enters (Y), the system ﺍﻟﻘﺎﺋﻣﺔ ﺍﻟﺭﺋﻳﺳﻳﺔ.
operates and then return to the main menu as before.
1.7 CONCLUSION
As we mentioned previously, the main objective of ﻛﻣﺎ ﺫﻛﺭﻧﺎ ﺳﺎﺑﻘﺎ ﺇﻥ ﺍﻟﻬﺩﻑ ﺍﻟﺭﺋﻳﺳﻲ ﻣﻥ ﺩﺭﺍﺳﺔ ﻫﻳﺎﻛﻝ
studying Data Structures is to use it in the ﺍﻟﺑﻳﺎﻧﺎﺕ ﻫﻭ ﺍﺳﺗﺧﺩﺍﻣﻬﺎ ﻓﻲ ﺗﻁﻭﻳﺭ ﺍﻟﺑﺭﻣﺟﻳﺎﺕ ﺃﻱ ﺑﺭﻣﺟﺔ
development of computer applications. We have ﺍﻟﺗﻁﺑﻳﻘﺎﺕ ﻭﺍﻷﻧﻅﻣﺔ ﺍﻟﺣﺎﺳﻭﺑﻳﺔ .ﻭﻟﺻﻧﻊ ﻫﺫﻩ ﺍﻟﺗﻁﺑﻳﻘﺎﺕ
presented the steps to make applications free of errors ﻫﻧﺎﻟﻙ ﻋﺩﺩ ﻣﻥ ﺍﻟﺧﻁﻭﺍﺕ ﺍﻟﺗﻲ ﻳﺟﺏ ﺍﺗﺑﺎﻋﻬﺎ ﻟﻠﻭﺻﻭﻝ ﺇﻟﻰ
in simple way. In the following chapter, we will present ﺗﻁﺑﻳﻘﺎﺕ ﻧﺎﺟﺣﺔ ﻭﺧﺎﻟﻳﺔ ﻣﻥ ﺍﻷﺧﻁﺎء ،ﻭﻗﻣﻧﺎ ﺑﺷﺭﺡ ﻫﺫﻩ
how to write programs using C++, C#, and java ﺍﻟﺧﻁﻭﺍﺕ ﺑﺷﻛﻝ ﺑﺳﻳﻁ ﻓﻲ ﺍﻷﺟﺯﺍء ﺍﻟﺳﺎﺑﻘﺔ ﻭﺳﻧﻘﻭﻡ
programming languages. ﺑﻌﺭﺽ ﻛﻳﻔﻳﺔ ﺻﻧﻊ ﻫﺫﻩ ﺍﻟﺑﺭﺍﻣﺞ ﺑﺎﺳﺗﺧﺩﺍﻡ ﻟﻐﺎﺕ ﺍﻟﺑﺭﻣﺟﺔ
ﺳﻲ ++ﻭﺳﻲ #ﻭﺟﺎﻓﺎ ﻓﻲ ﺍﻟﻭﺣﺩﺓ ﺍﻟﺛﺎﻧﻳﺔ.
13
Practical Data Structures with C++, C#, and Java
1.8. EXERCISES
14
M.A. Eljinini
d. analyze programs
16. Add a fourth option to the books Application. This option is used to print a list of all the books.
17. Add a new option to the books Application, to print the borrowed books only.
18. Add a date attribute to the (Books) class, then add a new option to the menu to print all books
that are two weeks late.
19. Perform the steps, as described in this chapter, to design an application for reserving rooms in
a hotel. The new application allows for reserving rooms, returning rooms, searching for a room,
and printing all occupied rooms.
20. Design an application for renting cars. The new application allows users to rent a car, return a
car, search for a car, and print a list of rented cars.
15
Practical Data Structures with C++, C#, and Java
Dear Reader,
Thank you for your interest in my book. Please accept my sincere apologies for not
sharing the full text due to author/publisher agreements with some distributers.
I hope the above contents, which consist of table of contents, preface, and chapter
one, give you a good idea of what it is all about.
If you are still interested in my book, you may get the full copy from one of the
following sources:
Paperback: https://www.amazon.co.uk/dp/9957674005
E-Book: https://www.amazon.co.uk/dp/B082FLVH7V
Paperback: http://www.lulu.com/shop/ma-eljinini/practical-data-structures-with-c-c-
and-java/paperback/product-24446111.html
Jamalon (in Black & White – also offers home delivery service, and cash on
delivery for some regions)
Paperback: https://jamalon.com/en/catalog/product/view/id/37484836
Best Wishes,
Mohammad Ali H. Eljinini, Ph.D.
16