Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

online dormitory management system, Summaries of Computer Science

hgvhdjgukfegfkugduvjdgbjhdfilhlgh;ogfh,hckdvhdksnf,jeilufkshfsdf ghfyfgeyfjsdf

Typology: Summaries

2020/2021

Uploaded on 10/20/2021

kena-kenea
kena-kenea 🇪🇹

1 document

Partial preview of the text

Download online dormitory management system and more Summaries Computer Science in PDF only on Docsity! Computer science is the study of computers, including computational theory, hardware and software design, algorithms and the way humans interact with technology. an algorithm is a specific procedure for solving a well- defined computational problem. The development and analysis of algorithms is fundamental to all aspects of computer science: artificial inntelligence, databases, graphics, networking, operatig systems, security, and so on. ‘an algorithm 1s simply a set of steps used to complete a specific task.. : is a procedure or formula used for solving a problem. It is based on conducting a sequence of specified actions in which these actions describe how to do something, and your computer will do it exactly that way every time. A computer program is a collection of instructions to perform a specific task. For this, a computer program may need to store data, retrieve data, and perform computations on the data. is anamed location that can be used to store and organize data. And, an algorithm is a collection of steps to solve a particular problem. Learning data structures and algorithms allow us to write ent and optimized computer programs. An operating system is a specialized collection of software that stands between a computer’s hardware architecture and its applications. It performs a number of fundamental activities such as file system management, process , network interfacing, and resource sharing among the computer’s users. Operating systems have evolved in their complexity over time, beginning with the earliest computers in the 1960s. Scheduling of processes/work is done to finish the work on time. Different Scheduling Algorithms First Come First Serve (FCF S): Simplest scheduling algorithm that schedules according to arrival times of processes. First come first serve scheduling algorithm states that the process that requests the CPU first is allocated the CPU first. It is implemented by using the FIFO queue. When a process enters the ready queue, its PCB is linked onto the tail of the queue. When the CPU is free, it is allocated to the process at the head of the queue. The running process is then removed from the queue. FCFS is a non-preemptive scheduling algorithm. Note: First come first serve suffers from convoy effect. Shortest Job First (SJF): Process which have the shortest burst time are scheduled first. If two processes have the same burst time then FCFS is used to break the tie. It is a non- preemptive scheduling algorithm. Longest Job First (LJF): It is similar to SJF scheduling algorithm. But, in this scheduling algorithm, we give priority to the process having the longest burst time. This is non- preemptive in nature i.e., when any process starts executing, can’t be interrupted before complete execution. Shortest Remaining Time First (SRTF): It is preemptive mode of SJF algorithm in which jobs are schedule according to shortest remaining time. Longest Remaining Time First (LRTF): It is preemptive mode of LJF algorithm in which we give priority to the process having largest burst time remaining. Round Robin Scheduling: Each process is assigned a fixed time(Time Quantum/Time Slice) in cyclic way.It is designed especially for the time-sharing system. The ready queue is treated as a circular queue. Below is different time with respect to a process. Arrival Time: Time at which the process arrives in the ready queue. Completion Time: Time at which process completes its execution. Burst Time: Time required by a process for CPU execution. Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time - Arrival Time Waiting Time(W.T): Time Difference between turn around time and burst time. Waiting Time = Turn Around Time - Burst Time only at arrival or completion of processes. What is the average waiting time for the three processes? (A) 5.0 ms (B) 4.33 ms (C) 6.33 (D) 7.33 Solution : Answer: - (A) Process PO is allocated processor at 0 ms as there is no other process in the ready queue. PO is preempted after 1 ms as P1 arrives at 1 ms and burst time for P1 is less than remaining time of PO. Pl runs for 4ms. P2 arrived at 2 ms but P1 continued as burst time of P2 is longer than P1. After Pl completes, PO is scheduled again as the remaining time for PO is less than the burst time of P2. PO waits for 4 ms, P1 waits for O ms and P2 waits for 11 ms. So average waiting time is (0+44+11)/3 = 5. Process Arrival Time Burst Time Pl 0 5 P2 1 3 P3 2 3 P4 4 i What is the average turnaround time for these processes with the preemptive shortest remaining processing time first (SRPT) algorithm ? (A) 5.50 (B) 5.75 (C) 6.00 (D) 6.25 Answer (A) Solution: The following is Gantt Chart of execution P1 = p2 P4P. PL a 4 5 8 12 Turn Around Time = Completion Time - Arrival Time Avg Turn Around Time 5.50 (12+3+6+ 1)/4= Process Execution time Arrival time Pl 20 0 P2 25 15 P3 10 30 P4 15 45 What is the total waiting time for process P2? (A) 5 (B) 15 (C) 40 (D) 55 Answer (B) At time 0, P1 is the only process, P1 runs for 15 time units. At time 15, P2 arrives, but P1 has the shortest remaining time. So P1 continues for 5 more time units. At time 20, P2 is the only process. So it runs for 10 time units At time 30, P3 is the shortest remaining time process. So it runs for 10 time units At time 40, P2 runs as it is the only process. P2 runs for 5 time units. At time 45, P3 arrives, but P2 has the shortest remaining time. So P2 continues for 10 more time units. P2 completes its execution at time 55 Total waiting time for P2 = Completion time - (Arrival time + Execution time) =55 - (15 + 25) = 15 Deadlock is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. ... Similar situation occurs in operating systems when there are two or more processes hold some resources and wait for resources held by other(s). DEADLOCK 4 Definition: A deadlock is a situation in which two computer programs sharing the same resource are effectively preventing each other from accessing the resource, resulting in both programs ceasing to function. © The reason, why earliest computer OS ran only one program at atime. © Aset of processes is deadlocked if each process in the set is waiting for an event that only another process can trigger. ¢ The database normalization process is further categorized into the following types: 1. First Normal Form (1 NF) 2. Second Normal Form (2 NF) 3. Third Normal Form (3 NF) A database is considered third normal form if it meet the requirements of the first 3 normal forms. The first normal form requires that a table satisfies the following conditions: 1. Rows are not ordered 2. Columns are not ordered 3. There is duplicated data 4. Row-and-column intersection always have a unique value 5. All columns are “regular” with no hidden values © Second Normal Form and Third Normal Form are all about the relationship between the columns that are the keys and the other columns that aren’t the key columns. An ina second normal form if all of its attributes depend on the whole primary key. So this means that the values in the different columns have a dependency on the other columns. 1. The table must be already in 1 NF and all non-key columns of the tables must depend on the PRIMARY KEY The partial dependencies are removed and placed in a separate table The third normal form states that you should eliminate fields in a table that do not depend on the key. 1. A Table is already in 2 NF 2. Non-Primary key columns shouldn’t depend on the other non-Primary key columns 3. There is no transitive functional dependency ‘What is Class in UML Diagram? A Class in UML diagram is a blueprint/design used to create an object or set of objects. The Class defines what an object can do. It is a template to create various objects and implement their behavior in the system. A Class in UML is represented by a rectangle that includes rows with class names, attributes, and operations. Whatis Class Diagram? A Class Diagram in Software engineering is a static structure that gives an overview of a software system by displaying classes, attributes, operations, and their relationships between each other. -This Diagram includes the class name, attributes, and operation in separate designated compartments. -Class Diagram helps construct the code for the software application oo nt. e Acclass diagram is a UML diagram. It represents classes and interfaces and how they associate with each other. ¢ Furthermore, a class diagram is a static diagram. Therefore, it provides a static view of the application. Also, this is one of the most common UML diagrams as it helps to model Object-oriented concepts. Benefits of Class Diagram ¢ Class Diagram Illustrate/show data models for even very complex information systems ¢ It provides an overview of how the application is structured before studying the actual code. ¢ This can easily reduce the maintenance time eIt helps for better understanding of general schematic of an application. «Allows drawing detailed charts which highlights code required to be programmed Helpful for developers and other stakeholders. Essential elements of A UML class diagram Essential elements of UML class diagram are: 1. Class Name 2. Attributes 3. Operations class name atuibate ca cont no: Var fSetcermme: Varar2) [ [eeu Vara Bios | Bod: No. : Varchari3) {Sut Comment [SReserved Varchar($) gperator, ‘ana Seed: venner ‘tate nt) trea verasrtt te 0 Sesex Cleary: Vartan) — sie Reon) [Srotesineorarb9 _—_ * [= Virdr) mar vy Jane Phone vert) IReLeame : Varchar(3)) Sstoreo stad: Vase) x ona |Resex: Varchac(8) = submt [Sesame Vareaar(?s) ea renew leona varcurcy lReracty: Varchar(30) iment Vercane(0) |ReBlock No : Varckax(3) Room Ne: Veer) combine ‘view Dorminf() SSubmit_Comment() r Roos |eioa Ne vata canes SstareQ Class:-The name of the class is only needed in the graphical representation of the class. It appears in the topmost section. A class is the blueprint of an object which can share the same relationships, attributes, operations, & semantics. The class is rendered as a rectangle, including its name, attributes, and operations in sperate compartments. n attribute is named property of a class which describes the . In the class diagram, this component is placed just below the name- compartment. Relationships There are mainly three kinds of relationships in UML: 1. Dependencies 2. Generalizations 3. Associations :- EXAMPLE © UML is the standard language for specifying, designing, and visualizing the artifacts of software systems A class is a blueprint for an object ¢ A class diagram describes the types of objects in the system and the different kinds of relationships which exist among them ¢ — It allows analysis and design of the static view of a software application ¢ Class diagrams are most important UML diagrams used for software application development ¢ Essential elements of UML class diagram are 1) Class 2) Attributes 3) Relationships ¢ Class Diagram provides an overview of how the application is structured before studying the actual code. It certainly reduces the maintenance time ¢ The class diagram is useful to map object-oriented programming languages like Java, C++, Ruby, Python, etc. ¢ The main difference between Class Diagram and Entity Relationship Diagram is that Class Diagram represents the classes and the associations among them in a software program while an Entity Relationship Diagram represents the entities and their relationships between them ina database. ¢ UML (Unified Modeling Language) is a standard modeling language to visualize and document a software system. There are various UML diagrams, and class diagram is one of them. It provides a static view of the system. On the other hand, A DATABASE is a collection of related data, which is essential to design a database before developing it. Moreover, entity relationship nian wks to ioe a databa: An Entity Relationship Diagram (ER diagram) helps to design a database. An entity is a real-world object. ER diagram represents the entities and their associations An Entiy-relationship model (ER model) describes the structure of a database with the help of a diagram, which is known as Entity Relationship Diagram (ER Diagram). An ER model is a design or blueprint of a database that can later be implemented as a database. The main components of E-R model are: ae set and relationship set. shows the relationship among entity sets. An entity set is a group of similar entities and these entities can have attributes. Helps to understand the static view of the tem 2. Attribute 3. Relationship Rectangle: Represents Entity sets. Ellipses: Attributes Diamonds: Relationship Set Lines: They link attributes to Entity Sets and Entity sets to Relationship Set Double Ellipses: Multivalued Attributes Dashed Ellipses: Derived Attributes Double Rectangles: Weak Entity Sets Double Lines: Total participation of an entity in a relationship set. SQL is a standard language for storing, manipulating and retrieving data in databases . SQL stands for Structured Query Language . SQL lets you access and manipulate databases . SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International an Ir Standardization (ISO) in 1987 . SQL can execute queries against a database . SQL can retrieve data from a database . SQL can insert records in a database . SQL can update records in a database . SQL can delete records from a database . SQL can create new databases . SQL can create new tables in a database . SQL can create stored procedures in a database . SQL can create views in a database . SQL can set permissions on tables, procedures, and views Database Tables . A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data. SELECT * FROM [Employees] select SELECT Country FROM Customers; select distinctive -The WHERE clause is used to filter records. -Note: The WHERE clause is not only used in SELECT statements, it is also used in UPDATE, DELETE, etc.! . SELECT * FROM Customers WHERE Countr lexico'; The WHERE clause can be combined with AND, OR, and NOT operators. The AND and OR operators are used to filter records based on more than one condition: . The AND operator displays a record if all the conditions separated by AND are TRUE. . The OR operator displays a record if any of the conditions separated by OR is TRUE. The NOT operator displays a record if the condition(s) is NOT TRUE. . SELECT * FROM Customers WHERE Country='Germany' AND City='Berlin'; . SELECT * FROM Customers WHERE City='Berlin' OR City='Mtinchen'; . SELECT * FROM Customers WHERE Country='Germany' OR Country='Spain'; . SELECT * FROM Customers WHERE NOT Country='Germany'; . SELECT * FROM Customers WHERE NOT ER BY ke 'Germany' AND NOT Country='USA'; The ORDER BY keyword is used to sort the result-set in ascending or descending order. . SELECT * FROM Customers ORDER BY Country; /SELECT * FROM Customers ORDER BY SERT IN CustomerName; The INSERT INTO statement is used to insert new records ina table. > INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen’, 'Skagen 21’ SOL UPD! '4006', 'Norway'); The UPDATE statement is used to modify the existing records ina table. > UPDATE Customers SET ContactName = ‘Alfred Schmidt’, City= 'Frankfurt' WHERE CustomerID = 1; > Update Warning!:Be careful when updating records. i ns omit the WHERE clause, ALL records will be updated! The DELETE statement is used to delete existing records in a table._ Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record(s) should be deleted. If you omit the WHERE clause, all records in the table will be deleted! > DELETE FROM Customers WHERE CustomerName=' Alfreds Futterkiste'; > DELETE FROM Customers; //=delete all record from customer rows The COUNT() function returns the number of rows that matches a specified criterion. > SELECT COUNT(ProductID) FROM Products; The AVG() function returns the average value of a numeric column. > SELECT AVG(Price) FROM Products; The SUM() function returns the total sum of a numeric column. > SELECT SUM(Quantity) FROM OrderDetails; The MIN() function returns the smallest value of the selected column. The MAX() function returns the largest value of the selected column. ¢ SELECT MIN(Price) AS SmallestPrice FROM Products; ¢ SELECT MAX(Price) AS LargestPrice FROM Products; ¢ SQL aliases are used to give a table, or a column ina table, a temporary name. ¢ Aliases are often used to make column names more readable. ¢ Analias only exists for the duration of that query. e Analias is created with the AS keyword. -SELECT column_name AS alias_name FROM table_name; -SELECT CustomerID AS ID, CustomerName AS Customer FROM Customers; Alias Table Syntax “+ SELECT column_name(s) FROM table_name AS alias_name; The SQL DROP DATABASE Statement The DROP DATABASE statement is used to drop an existing SQL database. Syntax DROP DATABASE databasename; e.g DROP DATABASE customers; The DROP TABLE statement is used to drop an existing table in a database. Syntax DROP TABLE table_name; e.g DROP TABLE customer; The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself. Syntax TRUNCATE TABLE table_name;
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved