Server Side Programming Articles - Page 1915 of 2646

C program for file Transfer using UDP?

Arnab Chakraborty
Updated on 29-Jan-2020 12:18:08

2K+ Views

Data can be shifted between two computers implementing Socket programming in C.In same case, files can easily be sent implementing User Datagram Protocol(UDP) and a simple client/server.Security − Handled by encryption.Protocol − UDPEncryption − XOR encryptionAlgorithmThe server is started and waited for filename.A filename is sent by the client.This filename is received by the server. If file is present, server starts reading file and is continued to send a buffer filled with file contents encrypted until and unless file-end is reached.End of File is marked by EOF.File is received as buffers until and unless EOF is received. After that it ... Read More

Binomial Heap in C++?

Arnab Chakraborty
Updated on 29-Jan-2020 12:10:57

546 Views

Binomial Heap is defined as an extension of Binary Heap that provides faster merge or union operation together with other operations provided by Binary Heap.A Binomial Heap is treated as a collection of Binomial Trees.What is a Binomial Tree?A Binomial Tree of order k can be built by taking two binomial trees of order k-1 and treating one as leftmost child or other.A Binomial Tree of order k has below properties.The number of nodes of Binomial Tree has exactly 2k.The depth of Binomial Tree is k.There are exactly kCi nodes at depth i where i = 0, 1, . . ... Read More

Binary Tree to Binary Search Tree Conversion using STL set C++?

Arnab Chakraborty
Updated on 29-Jan-2020 12:11:48

784 Views

In case of a given Binary Tree, convert it to a Binary Search Tree in such a way that keeps the original structure of Binary Tree intact.Sets of C++ STL will be used by this solution instead of array based solution.ExamplesExample 1Input     11     /  \    3    8 /     \ 9 5Output     9    /   \   5     11  /        \ 3        8Example 2Input      11      /   \     31    16    /        \  21 ... Read More

Required arguments in Python

Mohd Mohtashim
Updated on 30-Jan-2020 06:14:12

9K+ Views

Required arguments are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition.To call the function printme(), you definitely need to pass one argument, otherwise it gives a syntax error as follows −Example Live Demo#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme()OutputWhen the above code is executed, it produces the following result −Traceback (most recent call last): File "test.py", line 11, in printme(); TypeError: ... Read More

Binary Number System - Overflow in Arithmetic Addition in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 11:43:59

938 Views

2’s Complement Number System is widely implemented in computer architecture.N-bit 2’s Complement number System can be able to represent Number from -2n-1 to 2n-1- 14 Bit can be able to represent numbers from ( -8 to 7 )5 Bit can be able to represent numbers from ( -16 to 15 ) in 2’s Complementary System.Overflow happens with respect to addition when 2 N-bit 2’s Complement Numbers are appended and the answer is too large to fit into that N-bit Group.A computer contains N-Bit Fixed registers. Result of addition of two N-Bit Number will result maximum N+1 Bit number.Carry Flag stores ... Read More

Binary Indexed Tree or Fenwick Tree in C++?

Arnab Chakraborty
Updated on 29-Jan-2020 11:11:23

478 Views

In case of comparing with a flat array of numbers, the Fenwick tree results a much better balance between two operations: element update and prefix sum computation. In case of a flat array of m numbers, we can either store the elements, or the prefix sums. In case of first instance, calculating prefix sums needs linear time; in case of second instance, modifying or updating the array elements needs linear time (in both instances, the other operation can be accomplished in constant time). Fenwick trees permit both operations to be accomplished in O(log m) time. This is obtained by representing ... Read More

Bin Packing Problem (Minimize number of used Bins) in C++?

Arnab Chakraborty
Updated on 29-Jan-2020 11:08:42

4K+ Views

In case of given m elements of different weights and bins each of capacity C, assign each element to a bin so that number of total implemented bins is minimized. Assumption should be that all elements have weights less than bin capacity.ApplicationsPlacing data on multiple disks.Loading of containers like trucks.Packing advertisements in fixed length radio/TV station breaks.Job scheduling.ExampleInput: weight[] = {4, 1, 8, 1, 4, 2} Bin Capacity c = 10 Output: 2 We require at least 2 bins to accommodate all elements First bin consists {4, 4, 2} and second bin {8, 2}Lower BoundWe can always calculate a lower ... Read More

Pass by reference vs value in Python

SaiKrishna Tavva
Updated on 20-Nov-2024 17:40:48

12K+ Views

In Python Call by Value and Call by Reference are two types of generic methods to pass parameters to a function. In the Call-by-value method, the original value cannot be changed, whereas in Call-by-reference, the original value can bechanged. Call by Value in Python When we pass an argument to a function, it is stored locally (in the stack memory), i.e the scope of these variables lies with in the function and these will not have effect the values of the golbal variables (variables outside function). In Python, "passing by value" is possible only with the immutable types such as integers, floats, strings, ... Read More

Calling a Function in Python

Mohd Mohtashim
Updated on 29-Jan-2020 11:10:26

544 Views

Defining a function only gives it a name, specifies the parameters that are to be included in the function and structures the blocks of code.Once the basic structure of a function is finalized, you can execute it by calling it from another function or directly from the Python prompt. Following is the example to call printme() function − Live Demo#!/usr/bin/python # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call printme function printme("I'm first call to user defined function!") printme("Again second call to the same function")OutputWhen ... Read More

The calendar Module in Python

Mohd Mohtashim
Updated on 29-Jan-2020 11:09:25

651 Views

The calendar module supplies calendar-related functions, including functions to print a text calendar for a given month or year.By default, calendar takes Monday as the first day of the week and Sunday as the last one. To change this, call calendar.setfirstweekday() function.Here is a list of functions available with the calendar module −Sr.NoFunction with Description1calendar.calendar(year, w=2, l=1, c=6)Returns a multiline string with a calendar for year year formatted into three columns separated by c spaces. w is the width in characters of each date; each line has length 21*w+18+2*c. l is the number of lines for each week.2calendar.firstweekday( )Returns the current setting ... Read More

Advertisements