Enable contrast version

Tutor profile: Ryan B.

Inactive
Ryan B.
PA Board Certified Educator, Data Engineer, Former Chemist, and Computer Programmer with Decades of Experience
Tutor Satisfaction Guarantee

Questions

Subject: SQL Programming

TutorMe
Question:

List the different types of data relationships that occur when diagramming and designing database systems classified as Relational Database Management Systems (RDBMS) using SQL as their query language.

Inactive
Ryan B.
Answer:

1. One-to-One These are defined as the relationship between two tables where each record in one table is associated with the maximum of one record in the other table. 2. One-to-Many && Many-to-One: These relationships are the most common and occur where records in one table are associated with multiple records in the other table. 3. Many-to-Many : These relationships occur when multiple records in one table can be associated with multiple records in another table. 4. Self Referencing Relationships: These occur when records in a single table define associations with other records within the same single table.

Subject: Python Programming

TutorMe
Question:

Consider the following two lists: ```py3 a = [[1, 2, 3], [4, 5, 6],] b = a + a ``` After creating the new $$b$$ variable, you realize you need to change a value in one of the internal lists of $$b$$. You do so with the following: ```py3 b[0][0] = 10000 ``` You check $$b$$ and the value updates properly as you wanted. A day later, however, one of your team members receives a triage for a bug report. Turns out, the modification that was done to $$b$$, somehow was done to $$a$$, modifying $$a$$ against intentions. Your research, correctly, shows that list concatenation in python (+) creates a new list and doesn't mutate the original list to create the new list. In that case, how did this even happen?

Inactive
Ryan B.
Answer:

The process of list concatenation in python does create a new list, but, this new list ends up being shallow copies of the original list items. What this means is that, although a new list is created in memory, the contents of the list are shallow copied references from the original values in the lists that are concatenated, and the list items then in the new list actually are the same referenced ids in memory. Normally, then, modifying the list items isn't a big deal because you then replace one reference with another, but the problem here lies in the fact that the list items themselves are mutable lists with their own elements, and these elements technically are the same shallow copied shared references between the original lists and the new shallow copy that is made as well, so the change gets reflected back to all data structures that share the references. This is not a problem, however, when the elements in the outer list are immutable, like in the case of a string. Since you can't mutate a string further, there is never a risk of that reference changing as it does when the outer list contains mutable items that let you modify the references inside them.

Subject: Javascript Programming

TutorMe
Question:

Your day-to-day job involves leading a team of developers, who primarily work with Javascript as the main programming language. One of your duties in this role is to be available for pair programming and mentorship for your team members when they find themselves blocked with an issue. One day, one of your teammates comes to you after doing some research and debugging and is stumped and asks for your guidance. Here is the code block in question: ```js function greetingForAlan(person) { if (person === { name: 'Alan' }) { return 'Greetings, Alan!' } else { return 'You aren't Alan!' } } greetingForAlan({ name: 'Alan' }) ``` The function in question currently is returning "You aren't Alan!" but needs to return "Greetings, Alan". How would you adjust the code in order to get the desired return value? What led to the undesired return value, in other words, why did this error occur? Please explain as much information as possible utilizing references to the code block for support.

Inactive
Ryan B.
Answer:

The issue lies in the predicate of the if clause inside the function. Although it isn't readily visible, the object passed in as the argument of the function is equal to the hard-coded object literal if you consider the values the objects contain, however, in terms of the identity of those objects with regards to the memory addresses they are assigned to, they are actually two different objects. This would hold true regardless of loose(==) or strict(===) comparison and because they are two different objects in memory the if the predicate evaluates as false, and the else block will run instead producing the undesired outcome. In order to solve this issue and get the desired outcome, it would be best to compare the properties of the objects in some way instead. A possible solution would be as follows: ```js function greetingForAlan(person) { if (person.name === 'Alan') { return 'Greetings, Alan!' } else { return 'You aren't Alan!' } } greetingForAlan({ name: 'Alan' }) ```

Contact tutor

Send a message explaining your
needs and Ryan will reply soon.
Contact Ryan

Request lesson

Ready now? Request a lesson.
Start Lesson

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 Lesson" 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.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by Zovio
© 2013 - 2021 TutorMe, LLC
High Contrast Mode
On
Off