Composite Data Structures and Modularization
eBook - ePub

Composite Data Structures and Modularization

Volume 2: Composite Data Structures and Modularization

Xingni Zhou, Qiguang Miao, Lei Feng

  1. 298 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Composite Data Structures and Modularization

Volume 2: Composite Data Structures and Modularization

Xingni Zhou, Qiguang Miao, Lei Feng

Book details
Book preview
Table of contents
Citations

About This Book

This book covers C-Programming focussing on its practical side. Volume 2 deals mainly with composite data structures and their composition. An extensive use of figures and examples help to give a clear description of concepts and help the reader to gain a systematic understanding of the programming language.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Composite Data Structures and Modularization an online PDF/ePUB?
Yes, you can access Composite Data Structures and Modularization by Xingni Zhou, Qiguang Miao, Lei Feng in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming. We have over one million books available in our catalogue for you to explore.

Information

Publisher
De Gruyter
Year
2020
ISBN
9783110692501
Edition
1

1 Arrays

Main contents
  • Concept, usage, and available methods of arrays
  • Introduction of representation and nature of arrays through comparison between array/array elements and plain variables
  • Storage characteristics and debugging techniques of arrays
  • Programming techniques of multidimensional arrays
  • Top-down algorithm design practices
Learning objectives
  • Know how to define and initialize arrays as well as how to access array elements
  • Be able to define and use multidimensional arrays
  • Know how to deal with character arrays

1.1 Concept of arrays

Program statements and data construct programs. They are sequences of instructions created through algorithm design that conform to program control structures. However, are we able to solve all problems after learning statements, basic data types, program control structures, and algorithm implementation methods of C?
Let us look at a few problems in practice.

1.1.1 Processing data of the same type

Case study 1 Cracking Caesar code
Mr. Brown received an email from his son Daniel. However, the contents seemed a little weird for an email sent by someone in elementary school: it was a meaningless sequence “lettc fmvxlhec hehhc pszi csy”.
It later turned out that Daniel read a story of Julius Caesar and created an encrypted email using Caesar code to see whether his father could decrypt it.
During Roman times, Caesar invented the Caesar code to protect the information he exchanged with his generals on the front line from being intercepted by enemy spies. Encryption and decryption of Caesar code were done by shifting letters by a fixed number of positions. The plaintext alphabet was shifted forward or backward by a fixed number of positions to create the ciphertext alphabet. The number of positions shifted was the key for encryption and decryption of Caesar code, as shown in Figure 1.1.
Mr. Brown stared at the ciphertext and thought that it would not be hard to design an algorithm to solve the problem. He could simply shift each character in the ciphertext by one position in the alphabet and repeat this process 26 times to list all possible plaintexts, in which the one that is not nonsense would be the real plaintext. A universal algorithm could be designed using this technique to crack ciphertexts of arbitrary length.
  • If the length of the ciphertext is 2, we shift letters by one position in the alphabet each time and list all 26 possible plaintexts.
  • If the length of the ciphertext is 10, we shift letters by one position in the alphabet each time and list all 26 possible plaintexts.
  • If the length of the ciphertext is 100, we shift letters by one position in the alphabet each time and list all 26 possible plaintexts.
Figure 1.1: Encryption and decryption of Caesar code.
Think and discuss Necessary variables in password cracking
  1. How many variables are necessary for a program to handle 100 characters?
  2. How should we use these variables so that the program handles data in a convenient and unified manner?
Discussion: Solving a problem with computers involves two major steps: first, we should use reasonable data structures to describe the problem to store data into computers; second, we create algorithms to solve it. To answer the earlier questions, we need to find a mechanism that describes variables of the same type and handles them consistently.
Code implementation of the algorithm that solves Caesar codes is rather complicated, so we shall introduce it later. Before that, let us consider a reversed order problem that is more trivial.
Case study 2 Reversing 100 numbers
Write a program that reads 100 numbers and outputs them in a reversed order.
We are going to focus on how to handle variables of the same type. For a simpler description, we use variables with subscripts to represent the numbers, as shown in Figure 1.2.
Figure 1.2: Representation of 100 variables of the same type.
The flow of outputting 100 numbers backward is given in Figure 1.3. The program reads the numbers in a loop starting from X1, and outputs them using a loop starting from X100.
Variable Xi is uniquely identified by the value of i. We use x[i] to represent Xi in programs so we can type the names using keyboards.
The code implementation is as follows:
 01 int main(void ) 02 { 03 int i; 04 int x[100]; 05...

Table of contents

  1. Title Page
  2. Copyright
  3. Contents
  4. 1 Arrays
  5. 2 Pointers
  6. 3 Composite data
  7. 4 Functions
  8. 5 Files: operations on external data
  9. Index
Citation styles for Composite Data Structures and Modularization

APA 6 Citation

Zhou, X., Miao, Q., & Feng, L. (2020). Programming in C (1st ed.). De Gruyter. Retrieved from https://www.perlego.com/book/2107754/programming-in-c-volume-2-composite-data-structures-and-modularization-pdf (Original work published 2020)

Chicago Citation

Zhou, Xingni, Qiguang Miao, and Lei Feng. (2020) 2020. Programming in C. 1st ed. De Gruyter. https://www.perlego.com/book/2107754/programming-in-c-volume-2-composite-data-structures-and-modularization-pdf.

Harvard Citation

Zhou, X., Miao, Q. and Feng, L. (2020) Programming in C. 1st edn. De Gruyter. Available at: https://www.perlego.com/book/2107754/programming-in-c-volume-2-composite-data-structures-and-modularization-pdf (Accessed: 15 October 2022).

MLA 7 Citation

Zhou, Xingni, Qiguang Miao, and Lei Feng. Programming in C. 1st ed. De Gruyter, 2020. Web. 15 Oct. 2022.