karthikeya Boyini

karthikeya Boyini

1,421 Articles Published

Articles by karthikeya Boyini

Page 142 of 143

Print m multiplies of n without using any loop in Python.

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 314 Views

Given a number n, print m multiplies of n without using any loop. Here we use recursive function. Examples Input: n = 15 Output: 15 10 5 0 5 10 15 Algorithm Step 1: Given n. Step 2: If we are moving back toward the n and we have reached there, then we are done. Step 3: If we are moving toward 0 or negative. Step 4: If m is greater, then 5, recursive function with true flag else recursive function is false. Step 5: If m is not greater than 5 then flag is false. ...

Read More

How can we speed up Python "in" operator?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 637 Views

The python operator performs very badly in a list, O(n), because it traverses the whole list. You can use something like a set or a dict(hashed data structures that have very fast lookups) to get the same result in ~O(1) time!But this also depends on the type of data structure you're looking at. This is because while lookups in sets/dicts are fast, insertion may take more time than list. So this speedup really depends on the type.

Read More

What are the best practices for using if statements in Python?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 711 Views

Here are some of the steps that you can follow to optimize a nested if...elif...else.1. Ensure that the path that'll be taken most is near the top. This ensures that not multiple conditions are needed to be checked on the most executed path.2. Similarly, sort the paths by most use and put the conditions accordingly.3. Use short-circuiting to your advantage. If you have a statement like:if heavyOperation() and lightOperation():Then consider changing it toif lightOperation() and heavyOperation():This will ensure that heavyOperation is not even executed if lightOperation is false. Same can be done with or conditions as well.4. Try flattening the ...

Read More

Using activity in SAP for number range intervals and number range objects

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 170 Views

As the name indicates, activity 02 is for intervals while activity 17 is for objects. There can be a different number range interval for a given SAP number range interval.

Read More

How do Python dictionary hash lookups work?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 495 Views

Dicts are hash tables. No tree searching is used. Looking up a key is a nearly constant time(Amortized constant) operation, regardless of the size of the dict. It creates the hash of the key, then proceeds to find the location associated with the hashed value. If a collision listed address is encountered, it starts the collision resolution algorithm to find the actual value.This causes dictionaries to take up more space as they are sparse.

Read More

Difference between C++ string constants and character constants

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 938 Views

In C++, a character in single quotes is a character literal. It's of type char. For example, 'a' is of type char with a value 97 on an ASCII based system.A character or a string of characters together in double quotes represent a string literal. It's of type const char[] and refers to an array of size length of string + 1. That extra character is there for marking the string's ending.String literals can be arbitrarily long, such as "abcdefg". Character literals almost always contain just a single character. When these are being printed, string literals are printed till the ...

Read More

Can interfaces have constructors in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 803 Views

No, interfaces can’t have constructors for the following reasons − All the members of an interface are abstract, and since a constructor cannot be abstract. Still, if you try to write a constructor within an interface it will generate a compile time error. Example public interface InterfaceTest { InterfaceTest(){ } public abstract void display(); public abstract void show(); } Error C:\Sample>javac InterfaceTest.java InterfaceTest.java:2: error: expected public InterfaceTest(){ ^ 1 error

Read More

What is the difference between Component class and Container class in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 4K+ Views

The class Component is the abstract base class for the non-menu user-interface controls of AWT. A component represents an object with graphical representation. The class Container is the superclass for the containers of AWT. The container object can contain other AWT components.

Read More

Is it possible to exclude subclasses from the results displayed in backoffice in SAP?

SAP
karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 143 Views

You can uncheck the option - Include subtypes in a search bar and this will only give you the results of the parent type.

Read More

What is the Thread class in Java?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 494 Views

The java.lang.Thread class is a thread of execution in a program. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Following are the important points about Thread −Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority.Each thread may or may not also be marked as a daemon.There are two ways to create a new thread of execution.One is to declare a class to be a subclass of Thread.Another way to create a thread is to declare a class that implements the Runnable interface.

Read More
Showing 1411–1420 of 1,421 articles
Advertisements