Posts

C Program to Print Triangle Pattern | C Programming

Image
To draw the kite pattern, we use for a loop. The kite Pattern in c is easy to make using for loop. A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times. Syntax The syntax of a for loop in C programming language is for ( init; condition; increment ) { statement(s); } Here is the flow of control in a 'for' loop − The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears. Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and the flow of control jumps to the next statement just after the 'for' loop. After the body of the 'for' loop executes, the flow of control jumps back up to the increment statement. This statement allows you to update any loop cont

Purpose of System Call

Image
The Purpose of The System Call The interface between a process and an operating system is provided by system calls. In general, system calls are available as assembly language instructions. They are also included in the manuals used by the assembly-level programmers. System calls are usually made when a process in user mode requires access to a resource. Then it requests the kernel to provide the resource via a system call. In general, system calls are required in the following situations: If a file system requires the creation or deletion of files. Reading and writing from files also require a system call. Creation and management of new processes. Network connections also require system calls. This includes sending and receiving packets. Access to a hardware device such as a printer, scanner, etc. requires a system call. Types of System Calls There are mainly five types of system calls. These are explained in detail as follows: Process Control These system calls deals with p

Tree Data Structures and Priority Queues

Image
Tree Data Structures Tree is a collection of nodes. If the collection is empty the tree is empty otherwise it contains a distinct node called root (r) and zero or more sub-trees whose roots are directly connected to the node r by edges. The root of each tree is called child of r, and r the parent. Any node without a child is called leaf. We can also call the tree as a connected graph without a cycle. So there is a path from one node to any other nodes in the tree. The main concern with this data structure is due to the running time of most of the operation require O(logn). We can represent tree as an array or linked list. Some of the definitions Level h of a full tree has d^(h-1) nodes. The first h levels of a full tree have 1 + d + d^2 + …………………….. d^(h-1) = (d^h -1)/(d-1) Binary Search Trees BST has at most two children for each parent. In BST a key at each vertex must be greater than all the keys held by its left descendents and smaller or equal than all the keys held by its r

General Software Features and Trends

Image
General Software Features and Trends Introduction Nowadays software projects are becoming more and more complex — in size, sophistication, and technologies used. Most software products are used by a huge number of people, not only that, this software support different national languages and comes in different sizes and shapes — desktop, standard, professional, Enterprise Resource Planning (ERP) packages, and so on. Almost all application software products (like word processors, and ERP packages) support more than one hardware and/or software platform. For example, we have web browsers for the PC and Mac; we have database management systems that run on VMS, UNIX, Windows NT, Linux, and so on. The competition and the advancements in technology are driving software vendors to include additional functionality and new features to their products— just to stay in business. Information Technology is revolutionizing the way we live and work. Digital technology has given mankind the ability to

NP-Completeness | Tractable and Intractable Problems | Polynomial time reduction | DAA

Image
  NP-Completeness Most of the problems considered up to now can be solved by algorithms in worst-case polynomial time. There are many problems and it is not necessary that all the problems have an apparent solution. This concept, somehow, can be applied to solving the problem using computers. The computer can solve: some problems in a limited time e.g. sorting, some problems require an unmanageable amount of time e.g. Hamiltonian cycles, and some problems cannot be solved e.g. I-lasting Problem. In this section, we concentrate on the specific class of problems called NP-complete problems (will be defined later). Tractable and Intractable Problems We call problems as tractable or easy if the problem can be solved using polynomial-time algorithms. The problems that cannot be solved in polynomial time but require a super polynomial-time algorithm are called intractable or hard problems. There are many problems for which no algorithm with running time better than exponential time is kn

Introduction to the C programming Language

Image
  Introduction:- ±    C is a general-purpose high-level language ±    Father of C – Dennis Ritchie ±    Originally developed for the UNIX operating system ±    Implemented on the Digital Equipment Corporation, PDP-11 computer in 1972 ±    The UNIX operating system and all UNIX applications are written in the C language   C has now become a widely used professional language for various reasons: ±     Easy to learn ±     Structured language ±     It produces efficient programs ±     It can handle low-level activities ±     It can be compiled on a variety of computers Why we use C? ±    C was initially used for system development work, in particular the programs that make-up the operating system ±    C was adopted as a system development language because it produces code that runs nearly as fast as code written in assembly language. ±    Some examples of the use of C might be: °     Operating Systems °     Language Compilers  °     Assemblers °     Text Editors °     Network Drivers °   

Scope Variables and Return Statement in Python | Python Theory

Scope of Variables All variables in a program may not be accessible at all locations in that program. This depends on where you have declared a variable. The scope of a variable determines the portion of the program where you can access a particular identifier. There are two basic scopes of variables in Python − Global variables Local variables Global vs. Local variables Variables that are defined inside a function body has a local scope, and those defined outside have a global scope. This means that local variables can be accessed only inside the function in which they are declared, whereas global variables can be accessed throughout the program body by all functions. When you call a function, the variables declared inside it are brought into scope. Following is a simple example − total = 0; # This is global variable. # Function definition is here      def sum( arg1, arg2 ): # Add both the parameters and return them."      total = arg1 + arg2; # Here total