II PUC Computer Science Textbook PDF 2018
Document Details
Uploaded by Deleted User
2018
null
null
Tags
Summary
This textbook provides a comprehensive overview of computer science for second-year PUC students in Karnataka. It covers both theoretical and practical aspects of the subject, aligning with the NCERT curriculum.
Full Transcript
!)0,('(.) %,(.% *,-,#.2.))% # REVISED EDITION 2018 Department of Pre-University Education Malleshwaram, Bengaluru - 560 012 www.pue.kar.nic.in I Revised Edition - 2017 201...
!)0,('(.) %,(.% *,-,#.2.))% # REVISED EDITION 2018 Department of Pre-University Education Malleshwaram, Bengaluru - 560 012 www.pue.kar.nic.in I Revised Edition - 2017 2018 7 Director’s Message Dear Students, We at the Department of Pre-university Education, Karnataka strive to empower each student to dream big and equip them with the tools that enable them to reach new heights and successfully deal with the challenges of life. As Swami Vivekananda said, "Real education is that which enables one to stand on one's own legs". The course contents in this book are designed with the objective of equipping you well for the next level of study. We wish you well on your journey and look forward to you becoming a responsible citizen of the nation and give back to the betterment of the society. With best wishes, Sd/- C. Shikha, IAS Director Department of Pre University Education Bengaluru Preface Dr. P. Nagabhushan BE,MTech,Phd,FIE,FIETE Professor, Department of Studies in Computer Science Chief Nodal Officer, University of Mysore, Mysore-570 006 I am pleased to understand that Department of Pre-University Education, Govt. of Karnataka, took up an important academic exercise to revise the syllabi and accordingly came out with an appropriate text book, which is jointly authored by a committee of qualified and experienced faculty members drawn across Karnataka state. The committee of authors consisted of Sri. Rajappa, Empress Govt. PU College, Tumkur, as the Chairperson and Sri. Santus Xavio B K, Stracey Memorial PU College, Bengaluru as the Co-ordinator and Sri Nagaraje Urs, Maharaja Govt. PU College, Mysore, Smt. M R Nagamani, SBRR Mahajana PU College Mysore, Sri Ravindra K V, Govt. PU College, Sagara, Smt. Sharon Mednora, Govt PU College, Malleshwaram, Bengaluru, Sri. Naveen Kumar B, Govt. PU College for Girls, Malleshwaram, Bangalore and Smt. Padmashree R, NMKRV PU college, Bengaluru, as the members. When the committee members met me for seeking my remarks on the draft syllabus proposed, I felt comfortable to see the balanced distribution of topics to serve the needs of Commerce as well as Science students of PU Education. The spread and the organisation of the syllabus is quite good and care has been taken to see that the contents in Second Year Pre-University Course is properly placed as an extension to First PUC. The committee has ensured that the entire syllabus is on par with NCERT. The committee has put its best effort to provide a comprehensive coverage of both theoretical and practical aspects and also have paid careful attention to make the learners to acquire necessary skills, which makes the learners feel comfortable to work with the machine. I am happy to understand that the draft book is thoroughly reviewed by Dr. Somashekara M T, Bengaluru University and also by prof. Mukundappa, Tumkur University. The exercise problems set by the authors at the end of every chapter are good enough to keep the interests of the learners alive. I commend the excellent collective effort put by the committee of authors and also the two reviewers, and I am confident Second year PUC students of Karnataka would be greatly benefitted. III Computer Science Syllabus Review and Textbook Development Committee Department of Pre-University Education, Govt. of Karnataka AUTHORS Rajappa Chairperson Empress Govt. Pre-University College Tumakuru Co-ordinator: Santus Xavio B K Lecturer Stracey Memorial Pre-University College #52, St. Marks' Road, Bengaluru Members: Nagaraje Urs Lecturer Maharaja Govt. Pre-University College JLB Road, Mysore Sharon Mednora Lecturer Govt. Pre-University College 18th Cross, Malleshwaram Bengaluru Ravindra K V Lecturer Govt. Pre-University College Sagara, Shimoga District Nagamani M R Lecturer SBRR Mahajana Pre-University College Jayalakshmipuram, Mysore Padmashree R Lecturer NMKRV Pre-University College Jayanagar, Bengaluru IV Acknowledgements I am very fortunate to have esteemed personality Dr. Nagabhushan P, Professor, Dept. of Computer Science, Manasagangothri, University of Mysore who guided us in shaping the syllabus. We are also grateful to our reviewers Dr. Somashekar M T, Associate Professor, Dept. of Com- puter Science, Bengaluru University and Prof. Mukundappa , HOD, Dept. of Computer Science, University Science College, Tumkur. I whole heartedly thank them personally and on behalf of the committee. I acknowledge Sri. Marulaiah B, Principal, Empress Govt. PU College, Tumkur for his outstanding encouragement. I also thank A B Jagadish, P r i n c i p a th l Cross, Malleshwaram, Bengaluru who , G o v t. P U C o l l e g e , 1 8 helped us by providing the Computer Science laboratory. I also thank the College Management, SBMM Mahajana PU College, Jayalakshmipuram, Mysore for their support. We thank Dr. Serkad Arunachalam Kribanandan, Principal, Stracey Memorial PU College, Bengaluru for his overall support rendered to us. I proudly remember the service of Mr. Nagendrakumar K M, Lecturer, Govt. First Grade College, Tumkur who did fine DTP work amidst his busy engagements. I also thank Mr. Armstrong.M, former syllabus committee member, for his valuable suggestions and corrections. I also recall the support of my wife Shylaja. Last but not least, I acknowl- edge the support of family and friends of our committee members who directly or indirectly helped us in bringing out this text book. Rajappa Chairperson Computer Science Syllabus Review and Textbook Development Committee Department of Pre-University Education Govt. of Karnataka V Government of Karnataka Computer Science Syllabus Review Committee Department of Pre-University Education, Bengaluru Rajappa Santus Xavio B K Chairperson Co-ordinator Empress Govt. Pre-University College Stracey Memorial PU College Tumakuru Bengaluru e-mail: rajappatumkur @gmail.com [email protected] Reviewers: Dr. Nagabhushan P, Dept. of Computer Science, Manasagangothri, Mysore Dr. Somashekar M T, Dept. Computer Science, Gnanabharathi, Bengaluru Prof. Mukundappa, HOD, Dept of Computer Science, University Science College, Tumkur Members: Nagaraje Urs Lecturer Maharaja Govt. Pre-University College JLB Road, Mysore Sharon Mednora Lecturer Govt. Pre-University College 18th Cross, Malleshwaram, Bengaluru Ravindra K V Lecturer Govt. Pre-University College Sagara, Shimoga District Naveen Kumar B Lecturer Govt. Pre-University College 13th Cross, Malleshwaram, Bengaluru Nagamani M R Lecturer SBRR Mahajana Pre-University College Jayalakshmipuram, Mysore Padmashree R Lecturer NMKRV Pre-University College Jayanagar, Bengaluru VI Chapter No Topics Page No. UNIT A BACKDROP OF COMPUTERS 35 Hrs Chapter 1 Typical configuration of Computer system 1 1.1 Introduction 2 1.2 Motherboard 4 1.2.1 Introduction to Motherboard 4 1.2.2 Types of Motherboards 5 1.2.3 Components of Motherboard 6 1.3 Memory 15 1.4 Power supply to the computer system 18 1.5 Assembling the computer system 19 Chapter 2 Boolean Algebra 24 2.1 Introduction 25 2.2 Binary valued quantities-constants and variables 25 2.3 Logical operations 26 2.3.1 Logical functions or compound statements 26 2.3.2 Logical operators 26 2.4 Evaluation of Boolean expressions using truth table 29 2.4.1 Basic logic gates 34 2.5 Basic postulates of Boolean Algebra (with proof ) 36 2.5.1 Properties of 0 and 1 38 2.5.2 Indempotence law 41 2.5.3 Involution law 42 2.5.4 Complementarity law 43 2.5.5 Commutative law 44 2.5.6 Associative law 46 2.5.7 Distributive law-different forms 47 2.5.8 Absorption law 48 2.6 De Morgan’s theorems 50 2.6.1 De Morgan’s I theorem 50 2.6.2 De Morgan’s II theorem 51 2.6.3 Applications of De Morgan’s theorems 53 2.6.4 Basic duality of Boolean algebra 53 2.7 Derivation of Boolean expressions 54 2.7.1 Min terms 54 2.7.2 Max terms 57 2.7.3 Canonical expressions 57 2.7.4 Minimization of Boolean expressions 64 2.8 Simplification using Karnaugh map 65 2.8.1 Sum-of-product reduction using Karnaugh map 66 2.8.2 Product-of-sum reduction using Karnaugh map 76 VII Chapter 3 Logic gates 86 3.1 Introduction 87 3.1.1 Invertor (NOT gate) 87 3.1.2 OR gate 88 3.1.3 AND Gate 89 3.2 Derived Gates 90 3.2.1 NOR Gate 90 3.2.2 NAND Gate 91 3.2.3 XOR Gate 91 3.2.4 XNOR Gate 93 3.2.5 Circuit diagram 94 3.2.6 NAND,NOR as universal Gates 95 Chapter 4 DATA STRUCTURE 103 4.1 Introduction 104 4.2 Data representation 104 4.3 Classification of Data structures 105 4.3.1 Primitive Data structure 105 4.3.2 Operations on primitive data structures 106 4.3.3 Non-primitive Data structures 106 4.3.4 Linear data structure 107 4.3.5 Non-Linear data structure 107 4.4 Operations on linear data structures 107 4.5 Arrays 107 4.5.1 Types of array Memory representation of data 108 4.5.2 One dimensional array 109 4.5.3 Memory representation one dimensional array 109 4.5.4 Basic operations on one-dimensional array 109 4.5.5 Traversing using one dimension array 110 4.5.6 Searching an element 111 4.5.7 Insertion of an element 114 4.5.8 Deletion of an element 116 4.5.9 Sorting the elements 118 4.5.10 Two dimension Array 119 4.6 Stacks 123 4.6.1 Introduction 123 4.6.2 Representation of stacks in memory 124 4.6.3 Operations on stacks 127 4.6.4 Applications of Stacks 128 4.7 Queues 133 4.7.1 Introduction 133 4.7.2 Types of Queues 134 VIII 4.7.3 Operations on queues 136 4.7.4 Memory representation of queues 136 4.7.5 Applications of Queues 138 4.8 Linked lists 139 4.8.1 Introduction 139 4.8.2 Types of linked list 139 4.8.3 Operations on single linked lists 141 4.9 Non-Linear data structure 153 4.9.1 Introduction 153 4.9.2 Trees 153 4.9.3 Graphs 155 UNIT B COMPUTING IN C++ 45 Hrs Chapter 5 Review of C++ 158 5.1 Review of c++ language 158 5.2 Fundementals of c++ 160 5.3 Structure of c++ program 164 5.4 Libraray functions 164 5.5 Data types 165 5.6 Input and output operations 166 5.7 Control statements 167 5.8 Arrays 169 5.9 Functions 172 5.10 User-defined Functions 175 5.11 Structures 180 Chapter 6 Basic concepts of OOP 181 6.1 Introduction 182 6.2 Basic concepts of OOP 183 6.2.1 Objects 183 6.2.2 classses 183 6.2.3 Data Abstraction 184 6.2.4 Data Encapsulation 184 6.2.5 Inheritance 184 6.2.6 Overloading 185 6.2.7 Polymorphism 185 6.2.8 Dynamic Biding 185 6.2.9 Message passing 185 6.3 Advantages of OOP over earlier programming methods 186 6.4 Limitations of OOP 186 6.5 Applications of OOP 186 IX Chapter 7 Classes and objects 189 7.1 Introduction 190 7.2 Definition and declaration of classes and objects 191 7.3 Access specifiers (scope of class & its members) 193 7.3.1 Private 193 7.3.2 Public 193 7.3.3 Protected 194 7.4 Members of the class 194 7.5 Member functions 196 7.5.1 Member functions inside class definition 196 7.5.2 Member functions out side class definition 196 7.6 Defining objects of a class 198 7.7 Arrays as members of class 199 7.8 Array of objects 200 7.9 Objects as function arguments 202 7.10 Diffrences between structures and classes in C++ 204 Chapter 8 Function overloading 207 8.1 Introduction 208 8.2 Need for function overloading 208 8.3 Definition and declaration of overloaded function 208 8.4 Restrictions on overloaded function 209 8.4.1 Calling over loaded functions 209 8.5 Other functions in a class 210 8.5.1 Inline function 211 8.5.2 Friend function 212 Chapter 9 Constructor and Destructor 216 9.1 Introduction 217 9.2 Declaration and definition of constructor 218 9.3 Types of constructors 219 9.3.1 Default constructor 219 9.3.2 Parameterized constructor 221 9.3.3 Copy constructor 224 9.4 Constructor overloading 227 9.5 Destructor 228 Chapter 10 Inheritance(Extending classes) 232 10.1 Introduction 233 10.2 Base class 233 10.3 Derived class 233 10.3.1 Defining derived class 233 10.3.2 Public derived class 234 10.3.3 Private derived class 235 X 10.3.4 Protected dervied class 235 10.4 Visibility modes 235 10.4.1 Public inheritance 235 10.4.2 Private inheritance 236 10.4.3 Protected inheritance 236 10.5 Levels of inheritance 236 10.5.1 Single level inheritance 237 10.5.2 Multilevel inheritance 237 10.5.3 Multiple inheritance 238 10.5.4 Hierarchical inheritance 238 10.5.5 Hybrid inheritance 238 10.6 Relationship between classes 240 10.6.1 Virtual base classes 240 10.6.2 Abstract classes 242 10.6.3 Constructors in Derived classses 242 10.6.4 Destructors in Dervied classes 243 Chapter 11 Pointers 247 11.1 Introduction 248 11.2 Memory representation of pointers 248 11.3 Declaration & initialization of pointers 249 11.4 Address operator 249 11.5 Pointer operator(indirection operator) 250 11.6 Pointer arithmetic 250 11.7 Pointer and arrays 251 11.8 Arrays of pointers 252 11.9 Pointers to strings 253 11.10 Pointer as function parameters 253 11.11 Pointer and structures 254 11.12 Memory allocation of pointers(static and dynamic) 254 11.12.1 Static allocation of memory 254 11.12.2 Dynamic allocation of memory-new and delete 254 11.13 Free store (heap memory) 256 11.14 Memory leak 256 11.15 Self Referential Structure 256 11.16 Pointers and functions 257 11.16.1 Invoking functions by passing the references 257 11.16.2 Invoking functions by passing the pointers 258 11.17 Memory comes and memory goes 260 11.18 Pointer and objects 260 11.19 this pointer 261 XI Chapter 12 Data file handling 266 12.1 Introduction 267 12.2 Header files(fstream.h) 268 12.2.1 Classes for file stream operation 269 12.3 Types of data files 270 12.3.1 Text file 270 12.3.2 Binary file 270 12.4 Opening & closing files 270 12.4.1 Opening file using constructor 270 12.4.2 Using open() 271 12.4.3 File modes -In ,out, app modes 272 12.4.4 closing files 273 12.5 Input and output operation in text files 273 12.6 Detecting end of file 275 12.7 File pointers -tellg(), tellp(), seekg(), seekp() functions 275 UNIT C LARGE DATA, DATABASE & QUERIES 20 HRs Chapter 13 Database Concepts 282 13.1 Introduction 283 13.2 Appllications of database 284 13.3 Origin of Data : Facts,data,information,features 284 13.4 Evolution of database 285 13.5 Data processing cycle 286 13.6 Data base terms 287 13.7 Data Types in DBMS 288 13.8 DBMS 289 13.9 Data abstraction 291 13.10 Data independence 293 13.11 Database Model 298 13.11.1 Hierarchial data model 299 13.11.2 Network data Model 300 13.11.3 Relational Data model 301 13.12 Codd's Rules 302 13.13 Logical data concepts 304 13.13.1 Normalization 304 13.13.2 Entity-relationship Model 308 13.13.3 Cardinality 313 13.14 KEYS-Primary,Secondary,Candidate,Foreign, Alternate 315 13.15 Relational Algebra 318 13.16 Data warehousing 327 13.17 Data Mining 329 XII Chapter 14 Structured Query Language 333 14.1 Introduction 334 14.1.1 SQL Architecture 335 14.2 SQL commands 337 14.2.1 DDL 337 14.2.2 DML 338 14.3 Data types in SQL 339 14.3.1 Exact Numeric data types 339 14.3.2 Floating point Numeric data types 339 14.3.3 Date and time data types 339 14.3.4 Character and string data type 340 14.4 Operators in SQL 340 14.4.1 SQL arithemetic operators 340 14.4.2 Comparison operators 341 14.4.3 Logical operators 341 14.5 SQL expressions 342 14.5.1 SQL Boolean Expression 342 14.5.2 SQL Numeric expression 343 14.5.3 Date expression 343 14.6 SQL constraints 344 14.6.1 Primary key 344 14.6.2 Foreign Key or Referential integrity 346 14.6.3 Not NULL constraint 347 14.6.4 Unique Key 347 14.6.5 Check constraint 348 14.7 Implementation of SQL Commands 348 14.7.1 Create table statement 348 14.7.2 Alter 349 14.7.3 Insert Statement 350 14.7.4 Select statement 351 14.7.5 AND operator 353 14.7.6 OR operator 354 14.7.7 Update statement 354 14.7.8 Delete Statement 356 14.7.9 Order by 357 14.7.10 Group by 357 14.7.11 Distinct statement 359 14.7.12 Join 361 14.7.13 NULL 363 14.8.1 Create View 365 14.9.1 Commit 365 XIII 14.10 DCL commands 365 14.10.1 Grant command 365 14.10.2 Revoke command 366 14.11 Built-In Function 368 14.11.1 Single row function 368 14.11.2 Group function 368 UNIT D ADVANCED CONCEPTS IN COMMUNICATION TECHNOLOGY 20Hrs Chapter 15 Networking Concepts 375 15.1 Introduction 376 15.1.1 Networking Goals 376 15.1.2 Need of networking 376 15.2.1 Arpanet 376 15.2.2 OSI reference Model 377 15.2.3 TCP/IP 378 15.3.1 HTTP 380 15.3.2 FTP 381 15.3.3 SLIP 381 15.4.1 Internet 381 15.4.2 Interspace 382 15.4.3 Elementary terminologies of networking 382 15.4.4 Types of services 382 15.4.5 Types of networking 383 15.4.6 Networking Topologies 386 15.4.7 Transmission medium 393 15.4.8 Switching techniques 398 15.4.9 Communication modes 399 15.4.10 Networking devices 400 15.5.1 Gateway 403 15.6.1 SIM 404 15.7.1 GPRS 406 15.8.1 Applications of Networking 410 15.8.2 Wi-fi 411 15.9.1 Network security 411 15.10.1 Cookies 413 15.11.1 Virus 413 Chapter 16 Internet and Open source concepts 416 16.1 Introduction 416 16.1.2 Free software 417 16.1.3 Open source software 417 16.1.4 OSS and FLOSS 418 XIV 16.1.5 GNU 419 16.1.6 FSF 419 16.2.1 OSI 419 16.2.2 W3C 419 16.2.3 Proprietary software 419 16.2.4 www 420 16.2.5 Telnet 420 16.2.6 Web browser 420 16.2.7 Webserver 420 16.2.8 Webpage 421 16.3 URL and domain 421 16.4 E-Commerce 422 16.4.1 Types of E-commerce 424 16.4.2 Advantages of e-commerce 425 16.5 IPR issues 426 Chapter 17 Web designing 428 17.1 Introduction 429 17.1.1 HTML structure 430 17.2.1 Advanced HTML tags/commands 432 17.2.2 Text formating 432 17.2.3 Resizing text 432 17.2.4 Example for resizing text 433 17.2.5 Text layout 434 17.2.6 Number listing 435 17.2.7 Links 437 17.2.8 Inserting images 438 17.2.9 Background 439 17.2.10 Background color and fixed images 440 17.2.11 Tables 440 17.2.12 Frames 442 17.2.13 Forms 443 17.2.14 Settings and text fields 444 17.3.1 Web Hosting 447 17.3.2 Domain registration 448 17.4.1 Uploading HTML file 449 17.5.1 XML 450 17.6.1 DYNAMIC HTML 451 17.7.1 Web scripting 453 Model Question Paper 455 XV DESIGN OF QUESTION PAPER CLASS: SECOND PUC SUBJECT: COMPUTER SCIENCE (41) Time : 3Hours 15 Minutes(of which minutes for reading the questions Paper). Max.Marks:70 The weightage of the distribution of marks over different dimensions of the question paper shall be as follows: Weightage to Objectives: Objective Weightage Marks Knowledge 30% 31 Understanding 40% 43 Application 20% 21 Skill 10% 10 Total 100% 105 Weight age to Content/Subject units: Computer Science(41) Unit Description VSA(1 SA(2 LA(3 E(5Marks) Total Mark) Marks) Marks) Marks A BACKDROP OF COMPUTERS 3 2 3 3 31 35 Hrs B COMPUTING IN C++ 2 3 2 5 39 45Hrs C LARGE DATA, DATABASE & 1 2 1 2 18 20Hrs QUERIES D ADVANCED CONCEPTS IN 4 1 2 1 17 20Hrs COMMUNICATION TECHNOLOGY Total Marks 10 16 24 55 105 120 Total No of Questions to be 1X10=10 2X5/8=10 3X5/8=15 5X7/11=35 70/37 Hrs answered XVI VSA SA LA E Total UNIT DESCRIPTION (1 Mark) (2 Marks) (3 Marks) (5 Marks) Marks BACKDROP OF A 35 Hrs COMPUTERS 3 2 3 3 31 Chapter 1 Typical 5 Hrs configuration of 1 ------ 1 ------- 4 Computer system Chapter 2 Boolean algebra -------- 2 ----- 1 09 10 Hrs Chapter 3 Logic Gates 1 ------ 1 ------- 04 5 Hrs Chapter 4 Data structures 1 ------ 1 2 14 15 Hrs B COMPUTING IN C++ 2 3 2 5 39 45Hrs Chapter 5 Review of C++ 3 Hrs covered in First ------- ------- ------- ------ ---- PUC Chapter 6 OOP concepts ---- 1 ---- 1 07 4 Hrs Chapter 7 Classes and objects 1 ------ ----- 1 06 6 Hrs Chapter 8 Function ------ ------ ------ 1 05 3 Hrs Overloading Chapter 9 Constructors and ---- 1 ---- 1 07 8 Hrs Destructors Chapter 10 Inheritance ------ ----- ------ 1 05 8 Hrs Chapter 11 Pointers 1 ----- 1 ------ 04 7 Hrs Chapter 12 Data File handling ------- 1 1 ------ 05 6 Hrs LARGE DATA, C DATABASE & 1 2 1 2 18 20Hrs QUERIES Chapter 13 Database concepts 1 1 1 1 11 8 Hrs Chapter 14 SQL commands ------- 1 ----- 1 07 12 Hrs ADVANCED D CONCEPTS IN 4 1 2 1 17 20Hrs COMMUNICATIO N TECHNOLOGY Chapter 15 Networking 2 1 ---- 1 9 10 Hrs Concepts Chapter 16 Internet and Open 1 ---- 1 ----- 4 5 Hrs source concepts Chapter 17 Web Designing 5 Hrs 1 ----- 1 ------ 4 Total Marks 10 16 24 55 105 Total No of Questions to be 1X 10=10 2X 5/8=10 3X5/8=15 5X7/11=35 70/37 answered XVII List of programs to be conducted in practical sessions Section A C++ and Data structure 1. Write a program to find the frequency of presence an element in an array. 2. Write a program to insert an element into an array at a given position. 3. Write a program to delete an element from an array from a given position 4. Write a program to sort the elements of an array in ascending order using insertion sort. 5. Write a program to search for a given element in an array using Binary search method. 6. Write a program to create a class with data members principle, time and rate. Create member functions to accept data values to compute simple interest and to display the result. 7. Write a program to create a class with data members a, b, c and member functions to input data, compute the discriminant based on the following conditions and print the roots. If determinant=0, print the roots that are equal If the discriminant is>0, print the real roots If the discriminant