Computer Science Notes for Students.

5000 Words
Skip to content Computer Science 9 According to Syllabus (Test Your Skill) TOGGLE NAVIGATION Unit 1 – Problem Solving (Exercise Questions) 1.1. Answer the following questions: Q.1. In a farm, there are some cows and birds. If there are total 35 heads and 110 legs, then how many cows and birds are there? Q.2. Define problem analysis. Explain your answer along with an example. Q.3. Define an algorithm and argue on its role and importance in problem solving. Q.4. Suppose a problem has multiple algorithms. How would you choose the most efficient one. Explain with examples. Q.5. How do you determine requirements for a flowchart? Q.6. Explain types of test data. Q.7. Describe a trace table. 1.4. Draw the flowcharts for the following problems: Input two numbers n 1 and n2. Determine whether n 1 divides n2 or not. Input a year and determine whether it is a leap year or not. Input a number and calculate its factorial. Find LCM (Lease Common Multiple) of two numbers. Input a number and display its factors. Q.1. In a farm, there are some cows and birds. If there are total 35 heads and 110 legs, then how many cows and birds are there? Answer: If there are total 35 heads and 110 legs. then there are 20 cows and 15 birds in the farm. Each cow has four legs and each birds has two legs. Q.2. Define problem analysis. Explain your answer along with an example. Answer: Problem Analysis I Understanding a Problem Problem analysis is a process of understanding the given problem. It is very important to understand a problem before trying to solve it. A clear understanding of a problem helps the user to solve it correctly and easily. It also saves money, time and resources. For example, a riddle or puzzle can be solved easily after understanding it properly. Figure: Puzzle The following figure represents a problem to be solved. The red light represents a problem, the yellow light represents its analysis and the green light represents its solution. It shows that problem analysis brings us closer to the solution. Figure: From problem to solution Q.3. Define an algorithm and argue on its role and importance in problem solving. Answer: Algorithm An algorithm is a finite number of steps to solve a problem. The steps given in the algorithm are in a specific order. These steps must be followed in the same sequence to solve the problem. The steps may consist of input process, decision and output. The word “algorithm” comes from the name of Arabic writer Muhammad ibn Musa al-Khwarizml. Example An algorithm to make tea is as follows: Step 1: Start Step 2: Take a kettle. Step 3: Put water in the kettle. Step 4: Put the kettle on fire. Step 5: Add milk and sugar. Step 6: Wait till boils Step 7: Remove the kettle from fire. Step 8: End Role of Algorithm in Solving a Problem An algorithm plays an important role in solving a problem. It provides a step-by- step guide to solve a problem. It is a complete description of the solution. The process of solving a problem becomes simpler and easier with the help of algorithm. The computer programmer usually writes an algorithm first. The algorithm is then translated into computer program using any programming language. Sometimes, the user first draws the flowchart and then converts it- into an algorithm. Figure: Solving a Problem Q.4· Suppose a problem has multiple algorithms. How would you choose the most efficient one. Explain with examples. Answer: Efficiency of Algorithms A problem may be solved with multiple algorithms. Each algorithm is different in efficiency. The most efficient algorithm should be selected to solve the problem. The efficiency of an algorithm is measured on the basis of two factors as follows: 1. Number of Steps The number or steps in algorithm is an important factor to measure its efficiency. An algorithm is more efficient if it takes less number of steps to solve problem. 2. Space in Computer Memory The solution of’ a problem may need to store data in computer memory. For example, the input data and the results of any calculations are stored in the memory. The space in memory is also an important factor to measure the efficiency of an algorithm. An algorithm is more efficient if it takes less space in computer memory. An algorithm may have more number of’ steps but may. take less memory space. Another algorithm may have less number of steps but may take more memory space. The algorithm must be selected according to the requirements. An algorithm that takes less memory space may be selected if the computer does not have much memory space. Example 1 Suppose a problem can be solved with two different algorithms. The algorithm 1 solves the problem in 10 steps. The algorithm 2 solves the problem in 15 steps. In this situation, algorithm 1 is considered more efficient than algorithm 2. Example 2 Suppose the sum of the following series is required: 1 +2+3+4+5+ … +99 The above problem can be solved in different ways as follows: Solution 1 Start from number 1 and keep on adding all numbers till 99. The result is 4950. Solution 2 Make pairs of the numbers such as (1+99), (2+98), (3+97) … (49,51) where each pair gives the answer Count total number of pairs which is 49 and multiple it with 100. The result will be 49 x 100 = 4900. Add 50 as it cannot fit in any pair. The result is 4900 + 50 = 4950. Solution 3 Each of the above solution solves the problem in different number of steps. These solutions may take different memory space if they are used in computer. Q.5. How do you determine requirements for a flowchart? Answer: Determining Requirements for a Flowchart The user must determine different requirements for the given problem before constructing a flowchart. These requirements are as follows: Input Processing Decision Making Output Input The first step is to clearly determine the input to the flowchart. It is the data that is taken from the user. The input is determined from the problem statement. It is important to know the required number of inputs and their types. Processing The second step is to determine the type of processing required to get the output. The. processing is used to perform calculations and store the results. Some examples of processing are increasing or decreasing a value, adding, subtracting, multiplying or dividing the numbers etc. Decision Making Another important step is to determine the decision making in the flowchart. Some steps are performed based on a condition. Decision making is the process to check if a statement is true or false and perform the appropriate steps accordingly. Output The last step is to provide the required output. It is the final information that is given to the user in solving a problem. Q.6. Explain types of test data. Answer: It is important to create proper and efficient test data to improve the quality of the solution. Each type of solution may require different types of test data. Different types of test data are as follows: . 1. Valid Test Data A type of test data that is according, to the input requirements of an algorithm is called valid test data. Example Suppose an algorithm requires a positive number between 1 and 50 to calculate the square of the number. Any number from 1 to 50 will be considered as valid test data. 2. Invalid Test Data A type of test data that is not according to the input requirements of an algorithm is called invalid test data. It is important that the algorithm handles invalid data properly and shows relevant messages. Example Suppose an algorithm requires a positive number between 1 and 50 calculate the square of the number. Any number out of this range will be consider as invalid test data such as -1 and 63. The algorithm should notify the user that the input is wrong. 3. Boundary Test Data The smallest or the largest data values from the range of valid test data is called boundary test data. An algorithm is tested with the boundary test data to ensure that handles these values correctly. Example Suppose an algorithm requires a positive number between 1 and 50 calculate the square root of the number. The values 1 and 50 will be considered boundary test data. 4. Wrong Data Format The wrong data format means the values that are different than valid test data. Example Suppose an algorithm requires a positive number between 1 and 50 calculate the square root of the number. The wrong data format for this algorithm can be the values such as A “Hello” and -5.9 etc. It is always good to check how the solution works with the wrong data formats . 5. Absent Data The absent data means that the number of values given to the solution is less than expected. Example Suppose an algorithm requires three numbers to find the largest one. The algorithm should give relevant message to the user if the number of inputs is less than three. It is important to check how the solution works with the absent data. Q.7. Describe a trace table. Answer: Trace Table A trace table is a technique of testing the algorithm to ensure that it does not have any logical errors. The trace table usually consists of multiple rows and columns. Each column shows the name of the data element. Each row shows the value of data element in each step. Example The following algorithm finds the factorial of 5: Step 1: Start Step 2: Set n = 5 Step 3: Set c = 1 Step 4: Set fact = 1 Step 5: If c <= n Then Set fact = fact x c Else Goto Step 8 Step 6: Set c= c + 1 Step 7: Goto Step 5 Step 8: Print fact Step 9: End The following trace table indicates the values of each data elements in each step. It can be used to check the value of different data elements in different steps. It helps in identifying and correcting any logical errors in the algorithm. The blank cell in the table means there is no change. The symbol – means that a value is not related to the step. n c fact Step1 – – – Step2 5 – – Step3 1 Step4 1 Step5 1 Step6 2 Step7 Step5 2 Step6 3 Step7 Step5 6 Step6 4 Step7 Step5 24 Step6 5 Step7 Step5 120 Step6 6 Step7 Step8 Step9 Explanation Step 1: It indicates the start of the algorithm. It has no effect on any value. Step 2: It sets the value of n to 5. It has no effect on c and fact. Step 3: It sets the value of c to 1. It has no effect on n and fact. Step 4: It sets the value of fact to 1. The value of n and C is not changed Step 5: It calculates fact = fact x c and stores the result 1 in fact. Step 6: It sets the value of c to 2. Step 7: It has no effect on any value and moves the control back to Step 5.The same process repeats until the condition c <= n becomes false and the algorithm ends after displaying the value of fact. 1. Input two numbers n 1 and n2. Determine whether n 1 divides n2 or not. Answer: 2. Input a year and determine whether it is a leap year or not. Answer: 3. Input a number and calculate its factorial. Answer: 4. Find LCM (Lease Common Multiple) of two numbers. 5. Input a number and display its factors. Answer: Powered by RG. Software Solutions. Skip to content Computer Science 9 According to Syllabus (Test Your Skill) TOGGLE NAVIGATION Unit 2 – Binary System (Exercise Questions) 2.2. Answer the following questions. Q.1. Convert (69610)10 to hexadecimal. Q.2. Differentiate between volatile and non-volatile memory. Q.3. Store the word “Phone” in computer memory starting from address 7003 where each letter needs one byte to store in the memory. Q.4. Differentiate between temporary and permanent storage. 2.4. Perform the following conversions. Q.1. (ABCD)16 to binary. Q.2. (0010110010001101001)2 to hexadecimal. Q.1. Convert (69610)10 to hexadecimal. Answer: Example 4: 6961010 to Hexadecimal Ans: 6961010 = 10FEA16 Q.2. Differentiate between volatile and non-volatile memory. Answer: Memory Storage 1. Memory stores data temporary. 1. Storage stores data permanently. 2. It has high access speed. 2. It has low access speed. 3. It is more expensive. 3. It is less expensive. 4. It is generally smaller in size. 4. It is generally bigger in size. 5. Programs are loaded into memory 5. Programs are stored on storage during execution. when not executing. . 6. Its capacity is typically small. 6. Its capacity is typically large. 7. It is called primary memory. 7. It is called secondary memory. Q.3. Store the word “Phone” in computer memory starting from address 7003 where each letter needs one byte to store in the memory. Answer: The word “Phone” requires 5 bytes in memory as it contains five letters. The “Phone” shows the representation in computer memory as follows: Letter P H 0 n e Binary value 01010000 01101000 01101111 01101110 01100101 Memory address 3000 3001 3002 3003 3004 Q.4. Differentiate between temporary and permanent storage. Answer: Temporary storage holds the data as long as the power supply is connected to it The contents of temporary memory are lost as the power supply is disconnected. RAM is an example of temporary storage. The permanent storage holds the data even if the power supply is not connected to it. Hard drive is an example of permanent storage. Q.5. Write the truth table for X and Y where X = It is sunny Y = Today is Monday Answer: x Y X AND Y False False False False True False True False False True True True 2.4. Perform the following conversions. Q.1. (ABCD)16 to binary. Answer: The binary value of each hexadecimal digit is as follows: A=1010 B = 1011 C=1100 D= 1101 Combine all binary values to obtain the answer: (ABCD)16 = 10101011110011012 Q.2. (0010110010001101001)2 to hexadecimal. Answer: Step 1: Make groups ‘Of four binary digits from right to left. Add extra O’s to the left it required. 0001 0110 0100 0110 1001 Step 2: Convert each group into hexadecimal number. 1 6 4 6 9 So, 00101100100011010012= 1646916 Powered by RG. Software Solutions. Skip to content Computer Science 9 According to Syllabus (Test Your Skill) TOGGLE NAVIGATION Unit 3 – Networks (Exercise Questions) 3.3. Write short answers. Q.1. How client and server communicate with each other? Q.2. What are the main components of communication? Q.3. How telephone addressing relate with network addressing? Q.4. What is difference between static and dynamic IP? Q.5. Define communication channel. Q.6. Describe the working of web browser. Q.7. What is the difference between point-to-point and multipoint connection? Q.8. What is application sharing? Answer with the help of an example. Q.9. What are the advantages and disadvantages of star topology over bus topology? Q.10. In a client server model, is client software or hardware? Give reasons to support your answer. 3.4. Answer the following questions. Q.1. What is network topology? Describe bus, star, ring and mesh topologies with e diagram of each. Q.2. What is TCP/IP? Describe its five layers with their functions. Q.3. What are the advantages and disadvantages of star topology over bus topology? Q.4. What are the sizes of IPv4 and IPv6? Explain the method to calculate the size of these both standards. Q.1. How client and server communicate with each other? Answer: Server The server is a computer that provides services to other computers and devices connected to the network. The server controls access to the hardware, software and other resources on the network. It also provides centralized storage area for programs, data and information. Servers usually have more processing power, memory and hard disk space than clients. Some servers are known as dedicated servers. Different types of dedicated servers include file server, print server, database server and web server. A dedicated server is used to perform a specific task. For example, file server is used to store and manage files. Print server is used to manage printers and print jobs. Client The client is a computer in the network that is connected with a server to access different resources. The client sends request to server for resources. The server provides requested resource to client. The client is typically less powerful than server. In general, a client is a hardware device. A cell phone, laptop and desktop computer is a client. The client application is a software that is used to send a request from client to server. It provides an interface to send the request to the server. Web browser is an example of a client application. Client/Server Communication The communication between client end server is based on request and response. The client sends request to the server for resources. The server provides the requested resource to client. For example, a server may store the company’s email messages, The clients on the network access email messages on the server. The clients may be any user connected to the network using the computers or mobile devices. The client provides username and password to login. The server provides access to the email account after verifying the username and password. Figure: Client-Server Communication Q.2. What are the main components of communication? Answer: Data Communication Data communication is the exchange of messages between sending and receiving devices through a communication medium. The messages are the information that may be in the form of text, numbers, images, audio and video. Components of Data Communication A data communication system consists of hardware and software to transfer data from one place to another. Different components of data communication system are as follows: 1. Sender Sender is a device that sends the message. It initiates communication process. It is also called source or transmitter. A computer is normally used as sender in data communication systems . 2. Receiver Receiver is a device that receive the message. It is also called sink. The receiver must be capable of accepting a message. The receiver can be computer, printer or another computer related device. 3. Message The message is the data, information or instruction to be communicated. It may consist of text, number, picture, audio, video or a combination of these. 4. Protocol A protocol is a set of rules that governs data communication. It is a formal agreement between communication devices to send and receive information. The devices cannot communicate without protocol. 5. Transmission Medium Medium is the path that connects sender and receiver. It is used to transmit data. It is also called communication channel. The transmission medium can be wired or wireless. The wired transmission media are twisted pair cable, coaxial cable and fiber optic cable. The wireless transmission media include radio waves, microwaves and satellites etc. A device may have multiple transmission channels at a time. For example, mobile phone connected to the Internet uses data channel (3G, 4G, LTE) to access Internet. It uses voice channel for making calls. Figure: Components of data communication Q.3. How telephone addressing relate with network addressing? Answer: Mapping between Telephone & Network Addressing IP address acts as a telephone number. Suppose a user needs to call another person. The telephone number is required to make the call. Similarly, a device uses the IP address of the other device to communicate with it. Each device connected to the Internet has an IP address. All IP addresses are unique like the telephone numbers. All devices communicate with other devices using the IP addresses. The IP addresses can be static or dynamic. Static IP Address Static IP address is a type of IP address that remains the same every time the device is connected to the Internet. The server uses static IP address. Dynamic IP Address Dynamic IP address is a type of IP address that is assigned each time a device is connected to the Internet. The user computers typically use dynamic IP address. Q.4. What is difference between static and dynamic IP? Answer: Static IP address is a type of IP address that remains the same every time the device is connected to the Internet. Dynamic IP address is a type of IP address that is assigned each time the device is connected to Internet. Q.5. Define communication channel. Answer: The message in data communication is sent in the form of packets, Each message consists of two parts called payload and control information. 1. Payload Payload is the actual contents of the message. Suppose a user writes an email message to a friend. The content of the email message is the payload. 2. Control Information Control information contains the information about the sender and the receiver. It is also called header of the message. The control information is used to deliver the message to the receiver properly. The message cannot be delivered if the control information is wrong or missing. Example Suppose a school sends the result cords of all students to their home addresses. In this example, the detail on the result card is the payload. The address on the envelope is the control information. It will be used to deliver the result card to the related student. Q.6. Describe the working of web browser. Answer: Web browsers are used to access the World Wide Web. Web browsers and Web servers function together as a client-server system. As a client/server model, the browser is the client run on a computer that contacts the Web server and requests information. The Web server sends the information back to the Web browser. The web browser displays the results on the computer or other Internet-enabled device that supports a browser. Q.7. What is the difference between point-to-point and multipoint connection? Answer: A point-to-point connection refers to direct link between a sender and a receiver. Both devices are connected with one connection line. A multipoint connection refers to the link between one sender and multiple receivers. A single link can be shared by more/devices. Q.8. What is application sharing? Answer with the help of an example. Answer: Application Sharing The individual licensed copy of application software can be costly. The application can be shared over a network among many users to save a lot of money. In this case, the user does not need to purchase separate copy of the application for each computer. For example, the manager, cashier and ATM user use the same application. The bank balance of a user updated in one branch is shown in all branches immediately. Figure: Application Sharing Q.9. What are the advantages and disadvantages of star topology over bus topology? Answer: The advantages are that star topology is more reliable than bus topology. It is easy to manage and maintain than bus topology. The disadvantages are that it consumes more cable than bus topology. It is more expensive to implement than bus topology. Q.10. In a client server model, is client software or hardware? Give reasons to support your answer. Answer: In general, a client is a hardware device. A cell phone, laptop and desktop computer is a client. However, the software running on that hardware makes it a client. 3.4. Answer the following questions. Q.1. What is network topology? Describe bus, star, ring and mesh topologies with e diagram of each. Answer: Network Topology. A network can be arranged in different ways, The physical layout or arrangement of connected devices in a network is called network topology. It is the shape of a network. Different network topologies are as follows: Bus Topology Ring· Topology Star Topology Tree Topology Mesh Topology Bus Topology Bus topology is the simplest type of network, It supports a small number computers. In bus topology, all computers or devices are connected to a common communication medium. This medium is known as bus or backbone. The terminators are used at the end of a bus to absorb signals and stop them to travel backwards. Figure: Bus topology Working of Bus Network The sending computer sends the data and destination address through the bus. The data and address move from one computer to the other in the network. Each computer checks the address. If it matches with the address of a computer, the computer keeps the data. Otherwise the data moves to the next computer. Advantages It is simple and easy to use. It requires small length of cable to connect computers. It is less expensive. If one computer fails, it does not affect the rest of the network. Disadvantages It only supports small number of computers. The network speed slows down as the number of computers increases. The entire network stops working if there is a problem in the central cable. Star Topology All computers in star topology are connected to a central device called switch or hub with point to point link. Point to point link means there is dedicated link or cable between two devices. Other devices cannot use it. Star topology is mostly used in the client-server networks. Working of Star Network The sending computer sends the data to the central device. The central device sends data to the receiving computer. Each computer in star network communicates with the central device. Figure: Star topology Advantages It is easy to manage and modify network. Adding or removing computers can be done without disturbing the network. Finding faults become very simple. Disadvantages If central device such as hub or switch fails, the entire network breaks down. It requires a Large length of cable. It is more expensive. Ring Topology In ring topology, each computer is connected to the next computer with the last one connected to the first. A ring of computers is formed in this way. A ring co be unidirectional or bidirectional. In a unidirectional ring topology, data can be sent in one direction. It can be either clockwise or anticlockwise. In a bidirectional ring topology, data can travel in any direction. Working of Ring Network Every computer is connected to next computer in a ring. Each compute receives message from the previous computer and transmits it to the next computer. The message is passed from one computer to other until it reaches the correct destination computer. Figure: Ring topology Advantages It is less expensive than star topology. Every computer has equal access to the network. Disadvantages Failure of one computer in the ring can disable the whole network. Adding new computer or removing existing computer affects the network. Mesh Topology In a mesh topology, every device in the network is physically connected to every other device in the network. A message can be sent on different possible paths from source to destination more quickly. Mesh topology provides improved performance and reliability. Figure: Mesh topology Advantages The network continue working if one device on the network fails. It is more secure as the data remains between sender and receiver. It is more reliable as it provides point-to-point connection between two device Disadvantages Mesh technology is expensive as it uses a lot of wires. It is difficult to install and modify. Q.2. What is TCP/IP? Describe its five layers with their functions. Answer: Computer Networks Models Network model is used to manage the communication between computers on a network. A network model uses different layers to carry out communication. Each layer is used to perform different functions. Two popular types of network models are TCP/IP and OSI. TCP/IP TCP/IP stands for Transmission Control Protocol I Internet Protocol. TCP/IP is a network model that is used to transfer data from one computer to another over the Internet and other networks. Layers in TCP/IP TCP/IP model consists of five layers. Each layer usually has more than one protocols to carry out the functions. Each layer receives’ data from the layer above it. It adds some control information to the data known as header. The actual content of the message is hidden inside the header at each layer. This is called encapsulation. Different layers in TCP/IP model are as follows: 1. Application Layer The application layer is the top most layer of TCP/IP model. It provides an interface between network services and application programs. The users mostly interact with this layer. Many protocols are used at this layer to perform various functions. All these protocols collectively form the application layer. These protocols form the basics of various network services such as user login, file transfer, web surfing and email etc. FTP, h***: and SMTP are some’ examples of protocols used at application layer. Figure: The layers in TCP/IP model 2.Transport Layer The transport layer provides the mechanism to transport data between network devices. It controls the flow of data. It ensures that messages are delivered without any error. It divides large messages into small segments for efficient transmission. Th transport layer also provides the acknowledgement of successful data transmission. The data is retransmitted if there are any error’s in the transmission. Transmission Control Protocol (TCP) is an example of protocol used at transport layer. 3. Network Layer The network layer manages the delivery of data from source to destination across different networks. There may be many networks between two computers. This layer manages to send data from source computer to the destination computer. The network layer ‘finds the best physical path for the data to reach its destination. This process is called routing. internet Protocol (IP) is an example of protocol used at network layer. 4. Data Link Layer The data link layer manages the transfer of data between the devices on the same network. It also manages the flow and error control of data. It detects and retransmits faulty data. SK tk
Free reading for new users
Scan code to download app
Facebookexpand_more
  • author-avatar
    Writer
  • chap_listContents
  • likeADD