Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Ritesh J.
Computer Science graduate from University of Florida, Senior Software Engineer since last 4 years in Silicon Valley
Tutor Satisfaction Guarantee
Python Programming
TutorMe
Question:

Given a list of N numbers, use a single list comprehension to produce a new list that only contains those values that are: (a) even numbers, and (b) from elements in the original list that had even indices For example, if list[2] contains a value that is even, that value should be included in the new list, since it is also at an even index (i.e., 2) in the original list. However, if list[3] contains an even number, that number should not be included in the new list since it is at an odd index (i.e., 3) in the original list.

Ritesh J.
Answer:

A simple solution to this problem would be as follows [x for x in list[::2] if x%2 == 0] For example, given the following list: # 0 1 2 3 4 5 6 7 8 list = [ 1 , 3 , 5 , 8 , 10 , 13 , 18 , 36 , 78 ] the list comprehension [x for x in list[::2] if x%2 == 0] will evaluate to: [10, 18, 78] The expression works by first taking the numbers that are at the even indices, and then filtering out all the odd numbers.

Java Programming
TutorMe
Question:

What is immutable object? Can you write immutable object?I

Ritesh J.
Answer:

Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.

Computer Science (General)
TutorMe
Question:

Find Inorder Successor in a Binary Search Tree

Ritesh J.
Answer:

In a Binary Tree, Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the last node in Inoorder traversal. In Binary Search Tree, Inorder Successor of an input node can also be defined as the node with the smallest key greater than the key of input node. So, it is sometimes important to find next node in sorted order. The Algorithm is divided into two cases on the basis of right subtree of the input node being empty or not. 1) If right subtree of node under consideration is not NULL, then successor lies in right subtree. Do following. Go to right subtree and return the node with minimum key value in right subtree. 2) If right sbtree of node is NULL, then start from root and use search like technique. Do following. Travel down the tree, if a node’s data is greater than root’s data then go right side, otherwise go to left side. struct node * inOrderSuccessor(struct node *root, struct node *n) { if( n->right != NULL ) return minValue(n->right); struct node *succ = NULL; // Start from root and search for successor down the tree while (root != NULL) { if (n->data < root->data) { succ = root; root = root->left; } else if (n->data > root->data) root = root->right; else break; } return succ; }

Send a message explaining your
needs and Ritesh will reply soon.
Contact Ritesh
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.