Server Side Programming Articles - Page 1920 of 2650

A-Buffer Method in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:07:58

2K+ Views

A-Buffer technique in computer graphics is a simple hidden face detection mechanism used to medium scale virtual memory computers. This technique is also known as anti-aliased or area-averaged or accumulation buffer. This technique extends the algorithm of depth-buffer (or Z Buffer) technique. As the depth buffer technique can only be implemented for opaque object but not for transparent object, the A-buffer technique provides advantage in this scenario. Though the A buffer technique requires more memory, but different surface colors can be correctly composed implementing it. Being a descendent of the Z-buffer algorithm, each position in the buffer can locate or ... Read More

A Number Link Game in C/C++?

Arnab Chakraborty
Updated on 29-Jan-2020 07:04:03

268 Views

The Game − Suppose an n × n array of squares. Out of these, some of the squares are empty, some are solid, and some non-solid squares are set by integers 1, 2, 3, … .Each integer maintains or occupies exactly two different squares on the board. The task of the player is to connect the two occurrences of each integer on the board with the help of a simple path implementing horizontal and vertical movements alone. No two different paths are permitted to intersect one another. No path may include any solid square (solid squares are not permitted to ... Read More

3-way Merge Sort in C++

Aman Kumar
Updated on 29-Jul-2025 16:22:31

2K+ Views

Merge sort is a popular sorting algorithm that follows the divide-and-conquer strategy. It works by recursively dividing the input array into two halves, sorting each half, and then merging them. With a time complexity of O(n log n). 3-Way Merge Sort An optimized variation of merge sort is the 3-way merge sort, where the array is divided into three equal parts instead of two. This reduces the number of recursive calls and improves performance in certain scenarios. 3-Way Merge Sort algorithm Following are the steps (algorithm) to implement the 3-way merge sort: Divide the array ... Read More

2-3 Trees (Search and Insert) in C/C++?

Aman Kumar
Updated on 25-Jul-2025 17:12:28

983 Views

What is 2-3 Trees? A 2-3 tree is a tree data structure, where each internal node has either 2 or 3 children (also, we can say that 2-nodes and 3-nodes, respectively). It is a type of B-tree that ensures efficient search, insertion, and deletion operations with O(logn) time complexity. Properties of 2-3 tree 2-node contains one data element and has two children (or none if it is a leaf). 3-node contains two data elements and has three children (or none if it is a leaf). Data ... Read More

0/1 Knapsack using Branch and Bound in C/C++?

Ravi Ranjan
Updated on 05-May-2025 12:29:17

3K+ Views

In the 0-1 knapsack problem, a set of items is given, each with a weight and a value. We need to determine the number of each item to include in a collection so that the total weight is less than or equal to the given limit and the total value is as large as possible. What is Branch and Bound Algorithm?The branch and bound algorithm breaks the given problem into multiple sub-problems and then uses a bounding function. It eliminates only those solutions that cannot provide optimal solutions. In this article, we will discuss how to solve the 0-1 knapsack problem ... Read More

Getting formatted time in Python

Mohd Mohtashim
Updated on 28-Jan-2020 13:05:46

497 Views

You can format any time as per your requirement, but simple method to get time in readable format is asctime() −Example Live Demo#!/usr/bin/python import time; localtime = time.asctime( time.localtime(time.time()) ) print "Local current time :", localtimeOutputThis would produce the following result −Local current time : Tue Jan 13 10:17:09 2009

Getting current time in Python

Mohd Mohtashim
Updated on 28-Jan-2020 13:03:37

231 Views

To translate a time instant from a seconds since the epoch floating-point value into a time-tuple, pass the floating-point value to a function (e.g., localtime) that returns a time-tuple with all nine items valid.Example Live Demo#!/usr/bin/python import time; localtime = time.localtime(time.time()) print "Local current time :", localtimeOutputThis would produce the following result, which could be formatted in any other presentable form −Local current time : time.struct_time(tm_year=2013, tm_mon=7, tm_mday=17, tm_hour=21, tm_min=26, tm_sec=3, tm_wday=2, tm_yday=198, tm_isdst=0)

What is TimeTuple in Python?

Mohd Mohtashim
Updated on 28-Jan-2020 13:02:37

187 Views

Many of Python's time functions handle time as a tuple of 9 numbers, as shown below −IndexFieldValues04-digit year20081Month1 to 122Day1 to 313Hour0 to 234Minute0 to 595Second0 to 61 (60 or 61 are leap-seconds)6Day of Week0 to 6 (0 is Monday)7Day of year1 to 366 (Julian day)8Daylight savings-1, 0, 1, -1 means library determines DSTThe above tuple is equivalent to struct_time structure. This structure has following attributes −IndexAttributesValues0tm_year20081tm_mon1 to 122tm_mday1 to 313tm_hour0 to 234tm_min0 to 595tm_sec0 to 61 (60 or 61 are leap-seconds)6tm_wday0 to 6 (0 is Monday)7tm_yday1 to 366 (Julian day)8tm_isdst-1, 0, 1, -1 means library determines DSTRead More

Built-in Dictionary Functions & Methods in Python

Mohd Mohtashim
Updated on 28-Jan-2020 13:01:09

13K+ Views

Python includes the following dictionary functions −Sr.NoFunction with Description1cmp(dict1, dict2)Compares elements of both dict.2len(dict)Gives the total length of the dictionary. This would be equal to the number of items in the dictionary.3str(dict)Produces a printable string representation of a dictionary4type(variable)Returns the type of the passed variable. If passed variable is dictionary, then it would return a dictionary type.Python includes following dictionary methods −Sr.NoMethods with Description1dict.clear()Removes all elements of dictionary dict2dict.copy()Returns a shallow copy of dictionary dict3dict.fromkeys()Create a new dictionary with keys from seq and values set to value.4dict.get(key, default=None)For key key, returns value or default if key not in dictionary5dict.has_key(key)Returns true ... Read More

Properties of Dictionary Keys in Python

Mohd Mohtashim
Updated on 28-Jan-2020 13:00:22

4K+ Views

Dictionary values have no restrictions. They can be any arbitrary Python object, either standard objects or user-defined objects. However, same is not true for the keys.There are two important points to remember about dictionary keys −More than one entry per key not allowed. Which means no duplicate key is allowed. When duplicate keys encountered during assignment, the last assignment wins.ExampleFollowing is a simple example − Live Demo#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7, 'Name': 'Manni'} print "dict['Name']: ", dict['Name']OutputWhen the above code is executed, it produces the following result −dict['Name']: Manni Keys must be immutable. Which means you can use strings, ... Read More

Advertisements