NPTEL | Programming In Java| Week 1 : Assignment 1 Answers | July-2022

 


Week 1:Assignment 1

Due date: 2022-08-10, 23:59 IST.
Your last recorded submission was on 2022-07-29, 11:02 IST
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
You may submit any number of times before the due date. The final submission will be considered for grading.

netaji gandi Thursday, July 28, 2022
NPTEL | Programming, Data Structures And Algorithms Using Python | Week 1 : Assignment 1 Answers | July-2022

 



Week 1 Quiz

Due date: 2022-08-10, 23:59 IST.
Assignment not submitted
All questions carry equal weightage. All Python code is assumed to be executed using Python3. You may submit as many times as you like within the deadline. Your final submission will be graded.

Note:

  • If the question asks about a value of type string, remember to enclose your answer in single or double quotes.
  • If the question asks about a value of type list, remember to enclose your answer in square brackets and use commas to separate list items.

1. What does h(27993) return for the following function definition?

def h(x):
    (d,n) = (1,0)
    while d <= x:
        (d,n) = (d*3,n+1)
    return(n)
   Ans: 10



2.5 points

2. What is g(60) - g(48), given the definition of g below?

def g(n): 
    s=0
    for i in range(2,n):
        if n%i == 0:
           s = s+1
    return(s)
   Ans: 2





2.5 points
2.5 points

3. Consider the following function f.

def f(n): 
    s=0
    for i in range(1,n+1):
        if n//i == i and n%i == 0:
           s = 1
    return(s%2 == 1)

The function f(n) given above returns True for a positive number n if and only if:

 
 
 
 
2.5 points

4. Consider the following function foo.

def foo(m):
    if m == 0:
      return(0)
    else:
      return(m+foo(m-1))

Which of the following is correct?

 
 
 
 
You may submit any number of times before the due date. The final submission will be considered for grading.



netaji gandi
NPTEL | Problem Solving Through Programming In C | Week 1 : Assignment 1 Answers | July-2022

 


Week 1 : Assignment 1

Due date: 2022-08-10, 23:59 IST.
Assignment not submitted
1 point
The input given from keyboard is converted to computer understandable unit (bit) by the standard
 
 
 
 
1 point
The execution nature of C program is
 
 
 
 
1 point
Choose the correct statements from the following
i) In high-level language, testing and debugging a program is difficult than assembly language.
ii) C programs are highly portable on any type of operating system platform.
iii) A flowchart is a visual representation of the sequence of steps for solving a problem.
iv) The role of a compiler is to translate source program statements to decimal codes.
 
 
 
 
1 point
When we write X=Y in C, which of the following statements is valid?
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
 
 
 
 
1 point
The program which translates high level program into its equivalent machine language program is called
 
 
 
 
1 point
An interpreter reads the source code of a program
 
 
 
 
1 point
The C language has been developed at
 
 
 
 
You may submit any number of times before the due date. The final submission will be considered for grading.

netaji gandi
Graphes

 

A graph is a collection of nodes and edges. These nodes are connected by links(edges).
These edges may be directed or undirected. Moreover these edges can have weights associated with them

So edges can be categorized as :
  1. Directed, weighted edges
  2. Directed, unweighted edges
  3. Undirected, weighted edges
  4. Undirected, unweighted edges


Uses of graphs

Graphs are extremely useful. Look everywhere and one can easily find use of graphs. Listed below are a few of the vast set of practical uses of graphs.

Delhi Metro Rail Map
 Each station is a vertex, the distance in between is a weighted edge.

A Maze
 Each corner is a vertex, Line between two corners is and edge.

A tournament fixture
Courtesy: http://www.squadtd.com/
Each team is a vertex, match between the teams is an edge.


Kind of graphs

There are numerous classifications and types of graphs available. I have collected a few of those types from various sources and organized a list of types of graphs:

  • Undirected Graphs

Undirected Graph
     Characteristics:
  1. Order of vertices doesn't matter
  2. 1-2 is same as 2-1

  • Directed Graphs

Directed Graph
     Characteristics:
  1. Order of vertices does matter
  2. 1-2 is not same as 2-1

  • Vertex labeled Graphs.

Vertex Labeled Graph
     Characteristics:
  1. Each vertex contains additional information. e.g {2,orange}, {4,green}

  • Cyclic Graphs.

Cyclic Graph
     Characteristics:
  1. Graph contains at least one cycle.

  • Edge labeled Graphs.

Edge Labeled Graph
     Characteristics:
  1. Edge has labels e.g an edge in the above graph will be represented as {orange,green,{blue,cyan}}

  • Weighted Graphs.

Weighted Graph
     Characteristics:
  1. Each edge has some weight associated with it.

  • Directed Acyclic Graphs.

Direct Acyclic Graph(DAG)
     Characteristics:
  1. Graph has no cycles.

  • Disconnected Graphs

Disconnected Graph
     Characteristics:
  1. Vertices are disconnected 

  • Mixed graph

Mixed Graph
     Characteristics:
  1. Some edges may be directed and some may be undirected 

  • Multigraph

Multigraph
     Characteristics:
  1. Multiple edges (and sometimes loops) are allowed

  • Quiver

          

     Characteristics:
  1. Directed graph which may have more than one arrow from a given source to a given target. A quiver may also have directed loops in it.

Representation of graphs:

Fig. 1: An undirected graph
Fig 2: A directed graph
In order to use Graphs programatically , they need to be somehow represented in code. Following are the most widely used methods of representing a graph.

Adjacency Matrix : 

For N vertices an adjacency matrix is an NxN array A such that
                       A[i][j] = 1 if there is an edge E(i,j)
                                  = 0 otherwise

For an undirected graph, A[i][j] = A[j][i]

For weighted graphs,
                       A[i][j] = weight of the edge, if there is an edge E(i,j)
                                 = a constant representing no edge (e.g a very large or very small value)

For Fig 1, the adjacency matrix would be 

The adjacency matrix for directed graph in Fig 2 would be:


Adjacency List : 

Adjacency matrix representation consume a lot of memory (O[N2]). If the graph is complete or almost complete(i.e. contains most of the edges between the vertices), then this representation is good to use. But if there are very few edges as compared to number of vertices, it will unnecessarily consume extra space. Adjacency list can handle this situation very optimally.

Every vertex has a linked list of the vertices it is connected with.

Adjacency list for Fig 1 would be:


Adjacency list for Fig 2 would be:


netaji gandi Sunday, July 24, 2022

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...