Svcet Pcds Final

Embed Size (px)

Citation preview

  • 8/13/2019 Svcet Pcds Final

    1/21

    UNIT-1Introduction:

    Programs and Algorithms

    Features of an efficient algorithm

    Requirements for solving problems by computer

    The Problem Solving Aspect :

    Understand the Problem

    Formulate a Model

    Develop an Algorithm Write the Program

    Test the Program

    Evaluate the Solution

    Top Down Design : Definition

    Breaking a problem in to sub problems

    Choice of a suitable data structure

    Constructions of loops

    Establishing initial conditions for loops

    Finding the iterative construct

    Terminations of loops

  • 8/13/2019 Svcet Pcds Final

    2/21

    Implementation of Algorithms :

    Use of procedures to emphasize modularity

    Choice of variable name

    Documenting of programs

    Debugging Programs

    Program Testing & its explanation

    Program Verification: :

    Verification and Validation

    How Computer model for program execution is designed?

    Input (I/P) and Output (O/P) Assertions(statement/ argument)

    Implications and symbolic executions

    Verification of straight line program segments:

    Verification of program segments with branches

    Verification of program segment with loops

    Verification of program segments that employ arrays

    Proof of termination

  • 8/13/2019 Svcet Pcds Final

    3/21

    Efficiency of algorithms: :

    Types

    Redundant Computations

    Refactoring array elements

    Inefficiency due to late termination

    Early detection of desired O/P Conditions

    Trading Storage for efficiency gains

    The analysis of Algorithms:

    Why Algorithm analysis

    Computational Complexity

    The Order of Notation

    Worst and Average Case Behavior

    Probabilistic average case analysis

  • 8/13/2019 Svcet Pcds Final

    4/21

    UNIT - IIIntroduction to C LanguageBackground,

    Simple C Programme, Identifiers, Basic datatypes, Variables, Constants, Input / Output,Operators. Expressions, Precedence andAssociativity, Expression Evaluation, Type

    conversions, Bit wise operators, Statements,Simple C Programming examples. SelectionStatementsif and switch statements,Repetition statementswhile, for, do-whilestatements, Loop examples, otherstatements related to loopingbreak,continue, goto, Simple C Programmingexamples.

  • 8/13/2019 Svcet Pcds Final

    5/21

    Introduction to C Language Background:

    HISTORY

    Program Development Steps

    General Structure

    Example

    The four main components of C language are

    1) The Character Set (letters, digits, special symbols)

    2) Tokens (i. Keywords (32 auto,break,case,size of,struct,,void,volatile )

    ii. Identifiers(names of variables by rules)

    iii. Constants: (a)Numerical Constants

    i. Integer Constant : 1. Decimal Constant ,2. Octal Constant 3. Hexadecimal

    Constant

    ii. Float Constant

    (b)Character Constants : i. Single Character Constant, ii.String Constant

    Backslash Character Constants [Escape Sequences]: \n,\b,\o,\f,\t,\vFormat specifiers/ Delimiters :

    %cPrint a character

    %dPrint a decimalInteger

    %iPrint a Signed decimal integer

    %ePrint float value in exponential form. %fPrint float value

  • 8/13/2019 Svcet Pcds Final

    6/21

    iv. Punctuations(23 characters are used as punctuations in C. eg: + _ / ;

    : > ! etc)

    v. Operators:

    i. Arithmetic Operators : + - * / % ,ii. Assignment Operators : = ,

    iii. Relational Operators: = == != ,iv. Logical Operators:! && || ,v.Conditional Operators: ! : ,vi. Increment& Decrement Operator : ++ --,vii.

    Bitwise Operator:!& | ~ ^ ,viii. Special Operator :sizeof ,(comma)

    3) Variables(take on any value or a specified type

    4) Data Types :

    Simple or Fundamental data type or primary data type or atomic data types--- int,char,float,double

    Derived data typecombo of long,short,signed,unsigned with basic types

    User-defined data type (optional)enum,union,struct,typedef

    Input / Output: Unformatted I/O

    functions:getchar(),putchar(),gets(),puts() Formatted I/O functions:printf(),scanf()

    Expressions: combination of variables constants and operatorsAlgebraic Expression

    C Expression

    a x bc a * bc

    (m + n) (x + y) (m + n) * (x + y)

  • 8/13/2019 Svcet Pcds Final

    7/21

    Precedence and Associativity: High priority* / %, Low priority + - (rules)

    Expression Evaluation: Expression is

    evaluated first and then replaces theprevious value of the variable on the lefthand side 9use rules increment /decrement)

    Type conversions: Implicit andexplicit(casting) Bit wise operators: Logical Bitwise

    Operators, Shift bitwise

    Statements: conditional ,iterative andunconditional Selection Statementsif ,if else,nested if,if

    else if ladder ,switch statements(multi-waydecision making) ,Repetition statementswhile, for, do-while statements, jump

  • 8/13/2019 Svcet Pcds Final

    8/21

    Order of Presentation:

    History

    Definition

    UsageSyntax

    Initialization

    Declaration

    Assignment

    Accessing

    types

    Functions

    Inter Function Communication

    Complex FunctionsApplications/characteristics

    pros & cons

    Examples

  • 8/13/2019 Svcet Pcds Final

    9/21

    UNIT - III

    Designing Structured Programmes,Functions, basics, user defined functions,inter function communication, Standard

    functions, Scope, Storage classes-auto,register, static, extern, scope rules, typequalifiers, recursion- recursive functions,Preprocessor commands, example CprogrammesArraysConcepts, using arrays in C, interfunction communication, arrayapplications, twodimensional arrays,multidimensional arrays, C programme

    examples.

  • 8/13/2019 Svcet Pcds Final

    10/21

    Designing Structured Programmes: about top down design

    Functions: Library functions(sqrt,pow,abs,floor,ceil,trunk,round) & user defined

    functions

    fun. Definition, fun. Call, fun. Declaration

    categories based on arguments and return values (4 types)

    Passing Parameters to Functions / Parameter Passing Mechanisms:

    call by value and call by reference

    Inter function Communication :downward,upward,bidirectional

    Recursion

    Preprocessor Commands:#include /#include< >,

    Macro Definition-#define macro_name() macro_body, Nested Macros

    Undefining Macros: #define Val 30 #undef Val #define val 50

    Predefined Macros:_DATE_,_TIME_,_FILE_,_LINE_

    Symbolic Constants: #define PI 3.14159

    Conditional Compilation Commands: #if expression, #endif , #else , #elif , #ifdef

    name , #ifndef name Scope(rules & scope,lifetime,visibility)

    Storage classes-auto, register, static, extern

    type qualifiers: constant , volatile and restrict

    ArraysConcepts, using arrays in C

    inter function communication: Functions With Arrays / Passing arrays throughfunctions , Array of Strings

  • 8/13/2019 Svcet Pcds Final

    11/21

    UNIT - IV

    PointersIntroduction (Basic Concepts),Pointers for inter function communication,pointers to pointers, compatibility, memory

    allocation functions, array of pointers,programming applications, pointers tovoid, pointers to functions, commandlinearguments.StringsConcepts, C Strings, String Input/ Output functions, arrays of strings, stringmanipulation functions, string / dataconversion, C programme examples.

  • 8/13/2019 Svcet Pcds Final

    12/21

    PointersIntroduction (Basic Concepts): Pointer Constants,Pointer Values,Pointer Variables

    The & Operator: The unary or monadic operator & gives the``address of a variable''.The * Operator: The indirection ordereference operator gives the ``contents of an objectpointed

    to by a pointer'' Types of Pointers: near,far,huge,null,wild,generic,dangling

    Pointer arithmetic

    Pointers for inter function communication:Pointers andArrays[1D & 2D & n D ], Character pointer (or) Pointer and

    strings, Pointers And Functions (Pointer as functionargument: (Call by Reference) , Pointer to Function:(Function Returning Pointers) ) , Pointers and Structures ,Pointers To Pointers , Pointer to Void / Void Pointer,compatibility(poiinter of 1 data type storing into anotherformat) , array of pointers, programming applications

    memory allocation functions:malloc,realloc,calloc,free commandline arguments:- argc,argv

    StringsConcepts, C Strings, String Input / Outputfunctions(printf,scanf,puts,gets), arrays of strings, stringmanipulation functions(strcat,strcpy,strlen,strstr,strcmp),

    string / data conversion(a to I, I to a, a to f)

  • 8/13/2019 Svcet Pcds Final

    13/21

    UNIT - V

    Derived typesStructures

    Declaration, definition and initialization

    of structures, accessing structures,nested structures, arrays of structures,

    structures and functions, pointers to

    structures, self referential structures,unions, typedef, bit fields, enumerated

    types, C programming examples.

  • 8/13/2019 Svcet Pcds Final

    14/21

    Derived typesStructures: Tagged

    Structure ,Structure Variables , Typedef

    Structure

    Declaration, definition and initialization of

    structures, accessing structures(dot (.)

    operator, period operator ),Using De-

    Reference Operator * , Using SelectionOperator (->) ptr -> c or (*ptr).c ; ptr.i -> i

    or (*ptr).i;

    nested structures, arrays of structures,structures and functions, pointers to

    structures,

    self referential structures,

  • 8/13/2019 Svcet Pcds Final

    15/21

    UNIT - VI

    Input and OutputConcept of a file,

    streams, standard input / output

    functions, formatted input / outputfunctions, text files and binary files, file

    input / output operations, file status

    functions (error handling), C programmeexamples.

  • 8/13/2019 Svcet Pcds Final

    16/21

    Input and Output(stdio.h)Concept of a

    file(buffer and stream), streams(text and

    binary), standard input / outputfunctions(stdin & stdout) formatted input

    /

    output(printf,scanf,getchar,putchar,gets,p

    uts) functions, text files and binary files,file input / output

    operations(fprintf,fscanf,fopen,fclose,fget

    c,fputc,fgets,fputs,fread,fwrite, file statusfunctions (ftell,fseek,rewind), system file

    operations(fflush,rename,remove), error

    handling(feof (),ferror (),clearerr ())

  • 8/13/2019 Svcet Pcds Final

    17/21

  • 8/13/2019 Svcet Pcds Final

    18/21

    UNITVII

    Searching and SortingSorting-

    selection sort, bubble sort, insertion

    sort, quick sort, merge sort, Searching-linear and binary search methods ,

    Trees : representation , tree traversals.

  • 8/13/2019 Svcet Pcds Final

    19/21

    Searching and SortingSorting-selection sort, bubble sort, insertion sort,quick sort, merge sort, Searching-linear

    and binary search methods Trees : representation(preliminaries like

    level,depth,height,root,leaf,node,siblings,

    path,length,degree) Tree

    traversals(inorder,preorder,postorder,level order),representation of binary tree

    using linked and linear representation, Binary tree: Full binary tree, complete

    binary tree, strictly binary tree, binary

    search tree,BFS,DFS.

  • 8/13/2019 Svcet Pcds Final

    20/21

    UNIT - VIII

    Data StructuresIntroduction to Data

    Structures, abstract data types, Linear list

    singly linked list implementation,insertion, deletion and searching

    operations on linear list, Stacks-

    Operations, array and linked

    representations of stacks, stackapplication-infix to postfix conversion,

    postfix expression evaluation, recursion

    implementation, Queues-operations, array

  • 8/13/2019 Svcet Pcds Final

    21/21

    Data StructuresIntroduction to Data

    Structures, abstract data types,

    Linear listsingly linked listimplementation, insertion, deletion and

    searching operations on linear list,

    Stacks-Operations, array and linked

    representations of stacks, stack

    application-infix to postfix conversion,

    postfix expression evaluation, recursion

    implementation, Queues-operations, array and linked

    representations.